Mercurial > hg > orthanc-authorization
comparison Resources/SyncOrthancFolder.py @ 1:d5d3cb00556a
initial release
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 22 Mar 2017 16:13:52 +0100 |
parents | |
children | 52e041c8584a |
comparison
equal
deleted
inserted
replaced
0:decac5df19c4 | 1:d5d3cb00556a |
---|---|
1 #!/usr/bin/python | |
2 | |
3 # | |
4 # This maintenance script updates the content of the "Orthanc" folder | |
5 # to match the latest version of the Orthanc source code. | |
6 # | |
7 | |
8 import multiprocessing | |
9 import os | |
10 import stat | |
11 import urllib2 | |
12 | |
13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') | |
14 PLUGIN_SDK_VERSION = '1.1.0' # TODO Switch to 1.2.1 when available | |
15 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw' | |
16 | |
17 FILES = [ | |
18 'Core/Cache/LeastRecentlyUsedIndex.h', | |
19 'Core/Endianness.h', | |
20 'Core/Enumerations.cpp', | |
21 'Core/Enumerations.h', | |
22 'Core/Logging.cpp', | |
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 'Resources/WindowsResources.py', | |
47 'Resources/WindowsResources.rc', | |
48 ] | |
49 | |
50 SDK = [ | |
51 'orthanc/OrthancCPlugin.h', | |
52 ] | |
53 | |
54 EXE = [ | |
55 'Resources/EmbedResources.py', | |
56 'Resources/WindowsResources.py', | |
57 ] | |
58 | |
59 | |
60 def Download(x): | |
61 branch = x[0] | |
62 source = x[1] | |
63 target = os.path.join(TARGET, x[2]) | |
64 print target | |
65 | |
66 try: | |
67 os.makedirs(os.path.dirname(target)) | |
68 except: | |
69 pass | |
70 | |
71 url = '%s/%s/%s' % (REPOSITORY, branch, source) | |
72 | |
73 try: | |
74 with open(target, 'w') as f: | |
75 f.write(urllib2.urlopen(url).read()) | |
76 except: | |
77 print 'Cannot download %s' % url | |
78 raise | |
79 | |
80 | |
81 commands = [] | |
82 | |
83 for f in FILES: | |
84 commands.append([ 'default', f, f ]) | |
85 | |
86 for f in SDK: | |
87 commands.append([ | |
88 'Orthanc-%s' % PLUGIN_SDK_VERSION, | |
89 'Plugins/Include/%s' % f, | |
90 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) | |
91 ]) | |
92 | |
93 | |
94 pool = multiprocessing.Pool(10) # simultaneous downloads | |
95 pool.map(Download, commands) | |
96 | |
97 | |
98 for exe in EXE: | |
99 path = os.path.join(TARGET, exe) | |
100 st = os.stat(path) | |
101 os.chmod(path, st.st_mode | stat.S_IEXEC) | |
102 |