comparison Resources/SyncOrthancFolder.py @ 0:351ab0da0150

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Oct 2016 15:34:11 +0200
parents
children da2cf3ace87a
comparison
equal deleted inserted replaced
-1:000000000000 0:351ab0da0150
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
14 TARGET = os.path.join(os.path.dirname(__file__), '../Framework/Orthanc')
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',
47 'Core/Toolbox.cpp',
48 'Core/Toolbox.h',
49 'Core/WebServiceParameters.cpp',
50 'Core/WebServiceParameters.h',
51 'Resources/CMake/AutoGeneratedCode.cmake',
52 'Resources/CMake/BoostConfiguration.cmake',
53 'Resources/CMake/Compiler.cmake',
54 'Resources/CMake/DownloadPackage.cmake',
55 'Resources/CMake/JsonCppConfiguration.cmake',
56 'Resources/CMake/LibCurlConfiguration.cmake',
57 'Resources/CMake/LibIconvConfiguration.cmake',
58 'Resources/CMake/LibJpegConfiguration.cmake',
59 'Resources/CMake/LibPngConfiguration.cmake',
60 'Resources/CMake/OpenSslConfiguration.cmake',
61 'Resources/CMake/ZlibConfiguration.cmake',
62 'Resources/EmbedResources.py',
63 'Resources/MinGW-W64-Toolchain32.cmake',
64 'Resources/MinGW-W64-Toolchain64.cmake',
65 'Resources/MinGWToolchain.cmake',
66 'Resources/ThirdParty/VisualStudio/stdint.h',
67 'Resources/ThirdParty/base64/base64.cpp',
68 'Resources/ThirdParty/base64/base64.h',
69 'Resources/ThirdParty/patch/msys-1.0.dll',
70 'Resources/ThirdParty/patch/patch.exe',
71 'Resources/ThirdParty/patch/patch.exe.manifest',
72 'Resources/WindowsResources.py',
73 'Resources/WindowsResources.rc',
74 ]
75
76 EXE = [
77 'Resources/WindowsResources.py',
78 ]
79
80
81 def Download(x):
82 branch = x[0]
83 source = x[1]
84 target = os.path.join(TARGET, x[2])
85 print target
86
87 try:
88 os.makedirs(os.path.dirname(target))
89 except:
90 pass
91
92 url = '%s/%s/%s' % (REPOSITORY, branch, source)
93
94 with open(target, 'w') as f:
95 f.write(urllib2.urlopen(url).read())
96
97
98 commands = []
99
100 for f in FILES:
101 commands.append([ 'default', f, f ])
102
103
104 if sys.platform == 'win32':
105 # Sequential execution
106 for c in commands:
107 Download(c)
108 else:
109 # Concurrent downloads
110 pool = multiprocessing.Pool(10)
111 pool.map(Download, commands)
112
113
114 for exe in EXE:
115 path = os.path.join(TARGET, exe)
116 st = os.stat(path)
117 os.chmod(path, st.st_mode | stat.S_IEXEC)
118