annotate Resources/SyncOrthancFolder.py @ 208:315e1720a35f

documented orthanc.CreateImageFromBuffer()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jul 2024 12:56:18 +0200
parents 0c5da632f34d
children 240fac923e8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
132
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
1 #!/usr/bin/python3
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 #
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # This maintenance script updates the content of the "Orthanc" folder
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # to match the latest version of the Orthanc source code.
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 import multiprocessing
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 import os
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 import stat
175
c012edac593e patching the Orthanc SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
11 import subprocess
132
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
12 import urllib.request
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
187
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
15 ORTHANC_JAVA_VERSION = '1.0'
107
461dfb859ac7 upgrade to Orthanc SDK 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
16 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
17 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
18 ORTHANC_JAVA_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc-java/raw-file'
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 FILES = [
36
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
21 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
22 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
23 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
24 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'),
145
8b310d571e5b sync orthanc folder
Alain Mazy <am@osimis.io>
parents: 137
diff changeset
25 ('OrthancFramework/Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'),
8b310d571e5b sync orthanc folder
Alain Mazy <am@osimis.io>
parents: 137
diff changeset
26 ('OrthancFramework/Resources/EmbedResources.py', 'CMake'),
36
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
27 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', 'Toolchains'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
28 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', 'Toolchains'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
29 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', 'Toolchains'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
30 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', 'Toolchains'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
31 ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list', 'Plugins'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
32 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
33 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h', 'Plugins'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
34 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
35 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'),
fd58eb5749ed CMake simplification using DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
36 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'),
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 ]
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 def Download(x):
187
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
41 repository = x[0]
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
42 branch = x[1]
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
43 source = x[2]
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
44 target = os.path.join(TARGET, x[3])
132
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
45 print(target)
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 try:
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 os.makedirs(os.path.dirname(target))
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 except:
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 pass
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
187
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
52 url = '%s/%s/%s' % (repository, branch, source)
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
132
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
54 with open(target, 'wb') as f:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
55 try:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
56 f.write(urllib.request.urlopen(url).read())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
57 except:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
58 print('ERROR %s' % url)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 107
diff changeset
59 raise
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 commands = []
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 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
65 commands.append([
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
66 ORTHANC_CORE_REPOSITORY,
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
67 'default',
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
68 f[0],
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
69 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
70 ])
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
71
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
72
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
73 commands.append([
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
74 ORTHANC_JAVA_REPOSITORY,
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
75 'OrthancJava-%s' % ORTHANC_JAVA_VERSION,
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
76 '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
77 '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
78 ])
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
187
d08d75fc6d6a synchronization of the code model with orthanc-java project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
80
194
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
81 for f in [
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
82 'CodeModel.json',
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
83 'CodeModel.json.license',
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
84 'ClassDocumentation.json',
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
85 'ClassDocumentation.json.license',
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
86 ]:
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
87 commands.append([
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
88 ORTHANC_JAVA_REPOSITORY,
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
89 'OrthancJava-%s' % ORTHANC_JAVA_VERSION,
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
90 'CodeGeneration/%s' % f,
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
91 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f),
0c5da632f34d added description of classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
92 ])
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 pool = multiprocessing.Pool(10) # simultaneous downloads
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 pool.map(Download, commands)