Mercurial > hg > orthanc-python
annotate Resources/SyncOrthancFolder.py @ 227:9574f06d8588 default tip
todo
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 24 Sep 2024 08:54:11 +0200 |
parents | 3678a028f1f6 |
children |
rev | line source |
---|---|
132 | 1 #!/usr/bin/python3 |
0 | 2 |
219
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
3 # SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2024 Orthanc Team SRL, 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4 # SPDX-License-Identifier: AGPL-3.0-or-later |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
5 |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
6 ## |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
7 ## Python plugin for Orthanc |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
8 ## Copyright (C) 2020-2023 Osimis S.A., Belgium |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
9 ## Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
10 ## Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
11 ## |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
12 ## This program is free software: you can redistribute it and/or |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
13 ## modify it under the terms of the GNU Affero General Public License |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
14 ## as published by the Free Software Foundation, either version 3 of |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
15 ## the License, or (at your option) any later version. |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
16 ## |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
17 ## This program is distributed in the hope that it will be useful, but |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
18 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
20 ## Affero General Public License for more details. |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
21 ## |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
22 ## You should have received a copy of the GNU Affero General Public License |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
23 ## along with this program. If not, see <http://www.gnu.org/licenses/>. |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
24 ## |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
25 |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
26 |
0 | 27 # |
28 # This maintenance script updates the content of the "Orthanc" folder | |
29 # to match the latest version of the Orthanc source code. | |
30 # | |
31 | |
32 import multiprocessing | |
33 import os | |
34 import stat | |
175
c012edac593e
patching the Orthanc SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
145
diff
changeset
|
35 import subprocess |
132 | 36 import urllib.request |
0 | 37 |
38 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') | |
218 | 39 ORTHANC_JAVA_VERSION = 'default' |
107
461dfb859ac7
upgrade to Orthanc SDK 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
40 PLUGIN_SDK_VERSION = '1.10.0' |
187
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
41 ORTHANC_CORE_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file' |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
42 ORTHANC_JAVA_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc-java/raw-file' |
0 | 43 |
44 FILES = [ | |
36
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
45 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
46 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
47 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
48 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'), |
145 | 49 ('OrthancFramework/Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'), |
50 ('OrthancFramework/Resources/EmbedResources.py', 'CMake'), | |
36
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
51 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', 'Toolchains'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
52 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', 'Toolchains'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
53 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', 'Toolchains'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
54 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', 'Toolchains'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
55 ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list', 'Plugins'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
56 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
57 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h', 'Plugins'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
58 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
59 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'), |
fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
60 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'), |
0 | 61 ] |
62 | |
63 | |
64 def Download(x): | |
187
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
65 repository = x[0] |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
66 branch = x[1] |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
67 source = x[2] |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
68 target = os.path.join(TARGET, x[3]) |
132 | 69 print(target) |
0 | 70 |
71 try: | |
72 os.makedirs(os.path.dirname(target)) | |
73 except: | |
74 pass | |
75 | |
187
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
76 url = '%s/%s/%s' % (repository, branch, source) |
0 | 77 |
132 | 78 with open(target, 'wb') as f: |
79 try: | |
80 f.write(urllib.request.urlopen(url).read()) | |
81 except: | |
82 print('ERROR %s' % url) | |
83 raise | |
0 | 84 |
85 | |
86 commands = [] | |
87 | |
88 for f in FILES: | |
187
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
89 commands.append([ |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
90 ORTHANC_CORE_REPOSITORY, |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
91 'default', |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
92 f[0], |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
93 os.path.join(f[1], os.path.basename(f[0])) |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
94 ]) |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
95 |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
96 |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
97 commands.append([ |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
98 ORTHANC_JAVA_REPOSITORY, |
218 | 99 ORTHANC_JAVA_VERSION, |
187
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
100 'Resources/Orthanc/Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION, |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
101 'Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION, |
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
102 ]) |
0 | 103 |
187
d08d75fc6d6a
synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
175
diff
changeset
|
104 |
194
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
105 for f in [ |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
106 'CodeModel.json', |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
107 'CodeModel.json.license', |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
108 'ClassDocumentation.json', |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
109 'ClassDocumentation.json.license', |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
110 ]: |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
111 commands.append([ |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
112 ORTHANC_JAVA_REPOSITORY, |
218 | 113 ORTHANC_JAVA_VERSION, |
194
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
114 'CodeGeneration/%s' % f, |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
115 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f), |
0c5da632f34d
added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
116 ]) |
0 | 117 |
118 | |
119 pool = multiprocessing.Pool(10) # simultaneous downloads | |
120 pool.map(Download, commands) |