annotate Resources/SyncOrthancFolder.py @ 70:f73aed014bde wasm

OrthancAsynchronousWebService
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 May 2017 21:43:49 +0200
parents d20e25cfcf3a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 #
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # This maintenance script updates the content of the "Orthanc" folder
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # to match the latest version of the Orthanc source code.
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 import sys
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 import multiprocessing
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 import os
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 import stat
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 import urllib2
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
16
ff1e935768e7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 15
diff changeset
14 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw'
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 FILES = [
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 'Core/ChunkedBuffer.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 'Core/ChunkedBuffer.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 'Core/Compression/DeflateBaseCompressor.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 'Core/Compression/DeflateBaseCompressor.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 'Core/Compression/GzipCompressor.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 'Core/Compression/GzipCompressor.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 'Core/Compression/IBufferCompressor.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 'Core/Enumerations.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 'Core/Enumerations.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 'Core/HttpClient.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 'Core/HttpClient.h',
57
d20e25cfcf3a IWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 36
diff changeset
29 'Core/IDynamicObject.h',
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 'Core/Images/Image.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 'Core/Images/Image.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 'Core/Images/ImageAccessor.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 'Core/Images/ImageAccessor.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 'Core/Images/ImageBuffer.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 'Core/Images/ImageBuffer.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 'Core/Images/ImageProcessing.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 'Core/Images/ImageProcessing.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 'Core/Images/JpegErrorManager.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 'Core/Images/JpegErrorManager.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 'Core/Images/JpegReader.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 'Core/Images/JpegReader.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 'Core/Images/PngReader.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 'Core/Images/PngReader.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 'Core/Logging.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 'Core/Logging.h',
70
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
46 'Core/MultiThreading/SharedMessageQueue.cpp',
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
47 'Core/MultiThreading/SharedMessageQueue.h',
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 'Core/OrthancException.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 'Core/PrecompiledHeaders.h',
15
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
50 'Core/SystemToolbox.cpp',
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
51 'Core/SystemToolbox.h',
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 'Core/Toolbox.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 'Core/Toolbox.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 'Core/WebServiceParameters.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 'Core/WebServiceParameters.h',
31
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
56 'Plugins/Samples/Common/DicomDatasetReader.cpp',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
57 'Plugins/Samples/Common/DicomDatasetReader.h',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
58 'Plugins/Samples/Common/DicomPath.cpp',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
59 'Plugins/Samples/Common/DicomPath.h',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
60 'Plugins/Samples/Common/DicomTag.cpp',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
61 'Plugins/Samples/Common/DicomTag.h',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
62 'Plugins/Samples/Common/FullOrthancDataset.cpp',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
63 'Plugins/Samples/Common/FullOrthancDataset.h',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
64 'Plugins/Samples/Common/IDicomDataset.h',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
65 'Plugins/Samples/Common/IOrthancConnection.cpp',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
66 'Plugins/Samples/Common/IOrthancConnection.h',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
67 'Plugins/Samples/Common/OrthancHttpConnection.cpp',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
68 'Plugins/Samples/Common/OrthancHttpConnection.h',
9aace933cb64 sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
69 'Plugins/Samples/Common/OrthancPluginException.h',
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 'Resources/CMake/AutoGeneratedCode.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 'Resources/CMake/BoostConfiguration.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 'Resources/CMake/Compiler.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 'Resources/CMake/DownloadPackage.cmake',
20
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
74 'Resources/CMake/GoogleTestConfiguration.cmake',
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 'Resources/CMake/JsonCppConfiguration.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 'Resources/CMake/LibCurlConfiguration.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 'Resources/CMake/LibIconvConfiguration.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 'Resources/CMake/LibJpegConfiguration.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 'Resources/CMake/LibPngConfiguration.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 'Resources/CMake/OpenSslConfiguration.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 'Resources/CMake/ZlibConfiguration.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 'Resources/EmbedResources.py',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 'Resources/MinGW-W64-Toolchain32.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 'Resources/MinGW-W64-Toolchain64.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 'Resources/MinGWToolchain.cmake',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 'Resources/ThirdParty/VisualStudio/stdint.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 'Resources/ThirdParty/base64/base64.cpp',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 'Resources/ThirdParty/base64/base64.h',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 'Resources/ThirdParty/patch/msys-1.0.dll',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 'Resources/ThirdParty/patch/patch.exe',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 'Resources/ThirdParty/patch/patch.exe.manifest',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 'Resources/WindowsResources.py',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 'Resources/WindowsResources.rc',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 ]
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 EXE = [
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 'Resources/WindowsResources.py',
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 ]
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 def Download(x):
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 branch = x[0]
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 source = x[1]
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 target = os.path.join(TARGET, x[2])
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 print target
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 try:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 os.makedirs(os.path.dirname(target))
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 except:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 pass
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
23
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
112 url = '%s/%s/%s' % (REPOSITORY, branch, source)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 with open(target, 'w') as f:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 f.write(urllib2.urlopen(url).read())
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 commands = []
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 for f in FILES:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 commands.append([ 'default', f, f ])
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 if sys.platform == 'win32':
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 # Sequential execution
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 for c in commands:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 Download(c)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 else:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 # Concurrent downloads
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 pool = multiprocessing.Pool(10)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 pool.map(Download, commands)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 for exe in EXE:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 path = os.path.join(TARGET, exe)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 st = os.stat(path)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 os.chmod(path, st.st_mode | stat.S_IEXEC)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138