Mercurial > hg > orthanc-python
comparison Resources/SyncOrthancFolder.py @ 187:d08d75fc6d6a java-code-model
synchronization of the code model with orthanc-java project
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 02 Jul 2024 17:02:11 +0200 |
parents | c012edac593e |
children | 0c5da632f34d |
comparison
equal
deleted
inserted
replaced
186:55473de7694f | 187:d08d75fc6d6a |
---|---|
10 import stat | 10 import stat |
11 import subprocess | 11 import subprocess |
12 import urllib.request | 12 import urllib.request |
13 | 13 |
14 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') | 14 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') |
15 ORTHANC_JAVA_VERSION = '1.0' | |
15 PLUGIN_SDK_VERSION = '1.10.0' | 16 PLUGIN_SDK_VERSION = '1.10.0' |
16 REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file' | 17 ORTHANC_CORE_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file' |
18 ORTHANC_JAVA_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc-java/raw-file' | |
17 | 19 |
18 FILES = [ | 20 FILES = [ |
19 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'), | 21 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'), |
20 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'), | 22 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'), |
21 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'), | 23 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'), |
32 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'), | 34 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'), |
33 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'), | 35 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'), |
34 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'), | 36 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'), |
35 ] | 37 ] |
36 | 38 |
37 SDK = [ | |
38 'orthanc/OrthancCPlugin.h', | |
39 ] | |
40 | |
41 | 39 |
42 def Download(x): | 40 def Download(x): |
43 branch = x[0] | 41 repository = x[0] |
44 source = x[1] | 42 branch = x[1] |
45 target = os.path.join(TARGET, x[2]) | 43 source = x[2] |
44 target = os.path.join(TARGET, x[3]) | |
46 print(target) | 45 print(target) |
47 | 46 |
48 try: | 47 try: |
49 os.makedirs(os.path.dirname(target)) | 48 os.makedirs(os.path.dirname(target)) |
50 except: | 49 except: |
51 pass | 50 pass |
52 | 51 |
53 url = '%s/%s/%s' % (REPOSITORY, branch, source) | 52 url = '%s/%s/%s' % (repository, branch, source) |
54 | 53 |
55 with open(target, 'wb') as f: | 54 with open(target, 'wb') as f: |
56 try: | 55 try: |
57 f.write(urllib.request.urlopen(url).read()) | 56 f.write(urllib.request.urlopen(url).read()) |
58 except: | 57 except: |
61 | 60 |
62 | 61 |
63 commands = [] | 62 commands = [] |
64 | 63 |
65 for f in FILES: | 64 for f in FILES: |
66 commands.append([ 'default', | 65 commands.append([ |
67 f[0], | 66 ORTHANC_CORE_REPOSITORY, |
68 os.path.join(f[1], os.path.basename(f[0])) ]) | 67 'default', |
68 f[0], | |
69 os.path.join(f[1], os.path.basename(f[0])) | |
70 ]) | |
69 | 71 |
70 for f in SDK: | 72 |
71 commands.append([ | 73 commands.append([ |
72 'Orthanc-%s' % PLUGIN_SDK_VERSION, | 74 ORTHANC_JAVA_REPOSITORY, |
73 'OrthancServer/Plugins/Include/%s' % f, | 75 'OrthancJava-%s' % ORTHANC_JAVA_VERSION, |
74 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) | 76 'Resources/Orthanc/Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION, |
75 ]) | 77 'Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION, |
78 ]) | |
79 | |
80 | |
81 commands.append([ | |
82 ORTHANC_JAVA_REPOSITORY, | |
83 'OrthancJava-%s' % ORTHANC_JAVA_VERSION, | |
84 'CodeGeneration/CodeModel.json', | |
85 'Sdk-%s/CodeModel.json' % PLUGIN_SDK_VERSION, | |
86 ]) | |
87 | |
88 | |
89 commands.append([ | |
90 ORTHANC_JAVA_REPOSITORY, | |
91 'OrthancJava-%s' % ORTHANC_JAVA_VERSION, | |
92 'CodeGeneration/CodeModel.json.license', | |
93 'Sdk-%s/CodeModel.json.license' % PLUGIN_SDK_VERSION, | |
94 ]) | |
76 | 95 |
77 | 96 |
78 pool = multiprocessing.Pool(10) # simultaneous downloads | 97 pool = multiprocessing.Pool(10) # simultaneous downloads |
79 pool.map(Download, commands) | 98 pool.map(Download, commands) |
80 | |
81 # Patch the SDK, if need be | |
82 patch = os.path.join(os.path.abspath(os.path.dirname(__file__)), | |
83 'OrthancCPlugin-%s.patch' % PLUGIN_SDK_VERSION) | |
84 if os.path.exists(patch): | |
85 subprocess.check_call([ 'patch', '-p0', '-i', patch ], | |
86 cwd = os.path.join(os.path.dirname(__file__), | |
87 'Orthanc', | |
88 'Sdk-%s' % PLUGIN_SDK_VERSION, 'orthanc')) |