comparison Applications/Resources/SyncOrthancFolder.py @ 1538:d1806b4e4839

moving OrthancStone/Samples/ as Applications/Samples/
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Aug 2020 13:24:38 +0200
parents
children 8c5f9864545f
comparison
equal deleted inserted replaced
1537:de8cf5859e84 1538:d1806b4e4839
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.0.0'
15 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file'
16
17 FILES = [
18 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h', 'Plugins'),
19 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins'),
20 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'),
21 ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list', 'Plugins'),
22 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'),
23 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'),
24 ]
25
26 SDK = [
27 'orthanc/OrthancCPlugin.h',
28 ]
29
30
31 def Download(x):
32 branch = x[0]
33 source = x[1]
34 target = os.path.join(TARGET, x[2])
35 print target
36
37 try:
38 os.makedirs(os.path.dirname(target))
39 except:
40 pass
41
42 url = '%s/%s/%s' % (REPOSITORY, branch, source)
43
44 with open(target, 'w') as f:
45 f.write(urllib2.urlopen(url).read())
46
47
48 commands = []
49
50 for f in FILES:
51 commands.append([ 'default',
52 f[0],
53 os.path.join(f[1], os.path.basename(f[0])) ])
54
55 for f in SDK:
56 commands.append([
57 'Orthanc-%s' % PLUGIN_SDK_VERSION,
58 'Plugins/Include/%s' % f,
59 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f)
60 ])
61
62 pool = multiprocessing.Pool(10) # simultaneous downloads
63 pool.map(Download, commands)