comparison Resources/SyncOrthancFolder.py @ 0:7ed502b17b8f

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 26 Mar 2020 18:47:01 +0100
parents
children 777b677cc9fc
comparison
equal deleted inserted replaced
-1:000000000000 0:7ed502b17b8f
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 import subprocess
13
14 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
15 PLUGIN_SDK_VERSION = '1.5.7'
16 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file'
17
18 FILES = [
19 'Core/Compatibility.h',
20 'Plugins/Samples/Common/OrthancPluginCppWrapper.cpp',
21 'Plugins/Samples/Common/OrthancPluginCppWrapper.h',
22 'Plugins/Samples/Common/OrthancPluginException.h',
23 'Plugins/Samples/Common/VersionScript.map',
24 'Resources/CMake/BoostConfiguration.cmake',
25 'Resources/CMake/Compiler.cmake',
26 'Resources/CMake/DownloadPackage.cmake',
27 'Resources/CMake/JsonCppConfiguration.cmake',
28 'Resources/LinuxStandardBaseToolchain.cmake',
29 'Resources/MinGW-W64-Toolchain32.cmake',
30 'Resources/MinGW-W64-Toolchain64.cmake',
31 'Resources/MinGWToolchain.cmake',
32 'Resources/Patches/boost-1.69.0-linux-standard-base.patch',
33 ]
34
35 SDK = [
36 'orthanc/OrthancCPlugin.h',
37 ]
38
39
40 def Download(x):
41 branch = x[0]
42 source = x[1]
43 target = os.path.join(TARGET, x[2])
44 print target
45
46 try:
47 os.makedirs(os.path.dirname(target))
48 except:
49 pass
50
51 url = '%s/%s/%s' % (REPOSITORY, branch, source)
52 print('Downloading %s' % url)
53
54 with open(target, 'w') as f:
55 f.write(urllib2.urlopen(url).read())
56
57 print('Done %s' % url)
58
59
60
61 commands = []
62
63 for f in FILES:
64 commands.append([ 'default', f, f ])
65
66 for f in SDK:
67 commands.append([
68 'Orthanc-%s' % PLUGIN_SDK_VERSION,
69 'Plugins/Include/%s' % f,
70 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f)
71 ])
72
73
74 pool = multiprocessing.Pool(10) # simultaneous downloads
75 pool.map(Download, commands)
76
77
78 # Patch the SDK
79 subprocess.check_call([ 'patch', '-p0', '-i', os.path.join
80 (os.path.abspath(os.path.dirname(__file__)),
81 'OrthancCPlugin-%s.patch' % PLUGIN_SDK_VERSION) ],
82 cwd = os.path.join(os.path.dirname(__file__),
83 'Orthanc',
84 'Sdk-%s' % PLUGIN_SDK_VERSION, 'orthanc'))