0
|
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 sys
|
|
9 import multiprocessing
|
|
10 import os
|
|
11 import stat
|
|
12 import urllib2
|
|
13
|
16
|
14 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
|
0
|
15 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw'
|
|
16
|
|
17 FILES = [
|
|
18 'Core/ChunkedBuffer.cpp',
|
|
19 'Core/ChunkedBuffer.h',
|
|
20 'Core/Compression/DeflateBaseCompressor.cpp',
|
|
21 'Core/Compression/DeflateBaseCompressor.h',
|
|
22 'Core/Compression/GzipCompressor.cpp',
|
|
23 'Core/Compression/GzipCompressor.h',
|
|
24 'Core/Compression/IBufferCompressor.h',
|
|
25 'Core/Enumerations.cpp',
|
|
26 'Core/Enumerations.h',
|
|
27 'Core/HttpClient.cpp',
|
|
28 'Core/HttpClient.h',
|
|
29 'Core/Images/Image.cpp',
|
|
30 'Core/Images/Image.h',
|
|
31 'Core/Images/ImageAccessor.cpp',
|
|
32 'Core/Images/ImageAccessor.h',
|
|
33 'Core/Images/ImageBuffer.cpp',
|
|
34 'Core/Images/ImageBuffer.h',
|
|
35 'Core/Images/ImageProcessing.cpp',
|
|
36 'Core/Images/ImageProcessing.h',
|
|
37 'Core/Images/JpegErrorManager.cpp',
|
|
38 'Core/Images/JpegErrorManager.h',
|
|
39 'Core/Images/JpegReader.cpp',
|
|
40 'Core/Images/JpegReader.h',
|
|
41 'Core/Images/PngReader.cpp',
|
|
42 'Core/Images/PngReader.h',
|
|
43 'Core/Logging.cpp',
|
|
44 'Core/Logging.h',
|
|
45 'Core/OrthancException.h',
|
|
46 'Core/PrecompiledHeaders.h',
|
15
|
47 'Core/SystemToolbox.cpp',
|
|
48 'Core/SystemToolbox.h',
|
0
|
49 'Core/Toolbox.cpp',
|
|
50 'Core/Toolbox.h',
|
|
51 'Core/WebServiceParameters.cpp',
|
|
52 'Core/WebServiceParameters.h',
|
|
53 'Resources/CMake/AutoGeneratedCode.cmake',
|
|
54 'Resources/CMake/BoostConfiguration.cmake',
|
|
55 'Resources/CMake/Compiler.cmake',
|
|
56 'Resources/CMake/DownloadPackage.cmake',
|
|
57 'Resources/CMake/JsonCppConfiguration.cmake',
|
|
58 'Resources/CMake/LibCurlConfiguration.cmake',
|
|
59 'Resources/CMake/LibIconvConfiguration.cmake',
|
|
60 'Resources/CMake/LibJpegConfiguration.cmake',
|
|
61 'Resources/CMake/LibPngConfiguration.cmake',
|
|
62 'Resources/CMake/OpenSslConfiguration.cmake',
|
|
63 'Resources/CMake/ZlibConfiguration.cmake',
|
|
64 'Resources/EmbedResources.py',
|
|
65 'Resources/MinGW-W64-Toolchain32.cmake',
|
|
66 'Resources/MinGW-W64-Toolchain64.cmake',
|
|
67 'Resources/MinGWToolchain.cmake',
|
|
68 'Resources/ThirdParty/VisualStudio/stdint.h',
|
|
69 'Resources/ThirdParty/base64/base64.cpp',
|
|
70 'Resources/ThirdParty/base64/base64.h',
|
|
71 'Resources/ThirdParty/patch/msys-1.0.dll',
|
|
72 'Resources/ThirdParty/patch/patch.exe',
|
|
73 'Resources/ThirdParty/patch/patch.exe.manifest',
|
|
74 'Resources/WindowsResources.py',
|
|
75 'Resources/WindowsResources.rc',
|
|
76 ]
|
|
77
|
|
78 EXE = [
|
|
79 'Resources/WindowsResources.py',
|
|
80 ]
|
|
81
|
|
82
|
|
83 def Download(x):
|
|
84 branch = x[0]
|
|
85 source = x[1]
|
|
86 target = os.path.join(TARGET, x[2])
|
|
87 print target
|
|
88
|
|
89 try:
|
|
90 os.makedirs(os.path.dirname(target))
|
|
91 except:
|
|
92 pass
|
|
93
|
|
94 url = '%s/%s/%s' % (REPOSITORY, branch, source)
|
|
95
|
|
96 with open(target, 'w') as f:
|
|
97 f.write(urllib2.urlopen(url).read())
|
|
98
|
|
99
|
|
100 commands = []
|
|
101
|
|
102 for f in FILES:
|
|
103 commands.append([ 'default', f, f ])
|
|
104
|
|
105
|
|
106 if sys.platform == 'win32':
|
|
107 # Sequential execution
|
|
108 for c in commands:
|
|
109 Download(c)
|
|
110 else:
|
|
111 # Concurrent downloads
|
|
112 pool = multiprocessing.Pool(10)
|
|
113 pool.map(Download, commands)
|
|
114
|
|
115
|
|
116 for exe in EXE:
|
|
117 path = os.path.join(TARGET, exe)
|
|
118 st = os.stat(path)
|
|
119 os.chmod(path, st.st_mode | stat.S_IEXEC)
|
|
120
|