Mercurial > hg > orthanc-authorization
comparison Resources/SyncOrthancFolder.py @ 22:c44013681a51
now using the Orthanc framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 20 Jul 2018 14:37:30 +0200 |
parents | e252d740436f |
children | 79d871605ffd |
comparison
equal
deleted
inserted
replaced
20:549d67db766c | 22:c44013681a51 |
---|---|
9 import os | 9 import os |
10 import stat | 10 import stat |
11 import urllib2 | 11 import urllib2 |
12 | 12 |
13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') | 13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') |
14 PLUGIN_SDK_VERSION = '1.3.1' # TODO Switch to 1.2.1 when available | 14 PLUGIN_SDK_VERSION = '1.3.1' |
15 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw' | 15 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw' |
16 | 16 |
17 FILES = [ | 17 FILES = [ |
18 'Core/Cache/LeastRecentlyUsedIndex.h', | 18 'DownloadOrthancFramework.cmake', |
19 'Core/Endianness.h', | 19 'LinuxStandardBaseToolchain.cmake', |
20 'Core/Enumerations.cpp', | 20 'MinGW-W64-Toolchain32.cmake', |
21 'Core/Enumerations.h', | 21 'MinGW-W64-Toolchain64.cmake', |
22 'Core/Logging.cpp', | 22 'MinGWToolchain.cmake', |
23 'Core/Logging.h', | |
24 'Core/OrthancException.h', | |
25 'Core/PrecompiledHeaders.cpp', | |
26 'Core/PrecompiledHeaders.h', | |
27 'Core/Toolbox.cpp', | |
28 'Core/Toolbox.h', | |
29 'Plugins/Samples/Common/ExportedSymbols.list', | |
30 'Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', | |
31 'Plugins/Samples/Common/OrthancPluginCppWrapper.h', | |
32 'Plugins/Samples/Common/OrthancPluginException.h', | |
33 'Plugins/Samples/Common/VersionScript.map', | |
34 'Resources/CMake/AutoGeneratedCode.cmake', | |
35 'Resources/CMake/BoostConfiguration.cmake', | |
36 'Resources/CMake/Compiler.cmake', | |
37 'Resources/CMake/DownloadPackage.cmake', | |
38 'Resources/CMake/JsonCppConfiguration.cmake', | |
39 'Resources/EmbedResources.py', | |
40 'Resources/MinGW-W64-Toolchain32.cmake', | |
41 'Resources/MinGW-W64-Toolchain64.cmake', | |
42 'Resources/MinGWToolchain.cmake', | |
43 'Resources/ThirdParty/VisualStudio/stdint.h', | |
44 'Resources/ThirdParty/base64/base64.cpp', | |
45 'Resources/ThirdParty/base64/base64.h', | |
46 ] | 23 ] |
47 | 24 |
48 SDK = [ | 25 SDK = [ |
49 'orthanc/OrthancCPlugin.h', | 26 'orthanc/OrthancCPlugin.h', |
50 ] | |
51 | |
52 EXE = [ | |
53 'Resources/EmbedResources.py', | |
54 'Resources/WindowsResources.py', | |
55 ] | 27 ] |
56 | 28 |
57 | 29 |
58 def Download(x): | 30 def Download(x): |
59 branch = x[0] | 31 branch = x[0] |
66 except: | 38 except: |
67 pass | 39 pass |
68 | 40 |
69 url = '%s/%s/%s' % (REPOSITORY, branch, source) | 41 url = '%s/%s/%s' % (REPOSITORY, branch, source) |
70 | 42 |
71 try: | 43 with open(target, 'w') as f: |
72 with open(target, 'w') as f: | 44 f.write(urllib2.urlopen(url).read()) |
73 f.write(urllib2.urlopen(url).read()) | |
74 except: | |
75 print 'Cannot download %s' % url | |
76 raise | |
77 | 45 |
78 | 46 |
79 commands = [] | 47 commands = [] |
80 | 48 |
81 for f in FILES: | 49 for f in FILES: |
82 commands.append([ 'default', f, f ]) | 50 commands.append([ 'default', |
51 os.path.join('Resources', f), | |
52 f ]) | |
83 | 53 |
84 for f in SDK: | 54 for f in SDK: |
85 commands.append([ | 55 commands.append([ |
86 'Orthanc-%s' % PLUGIN_SDK_VERSION, | 56 'Orthanc-%s' % PLUGIN_SDK_VERSION, |
87 'Plugins/Include/%s' % f, | 57 'Plugins/Include/%s' % f, |
88 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) | 58 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) |
89 ]) | 59 ]) |
90 | 60 |
91 | 61 |
92 pool = multiprocessing.Pool(10) # simultaneous downloads | 62 pool = multiprocessing.Pool(10) # simultaneous downloads |
93 pool.map(Download, commands) | 63 pool.map(Download, commands) |
94 | |
95 | |
96 for exe in EXE: | |
97 path = os.path.join(TARGET, exe) | |
98 st = os.stat(path) | |
99 os.chmod(path, st.st_mode | stat.S_IEXEC) | |
100 |