comparison Resources/SyncOrthancFolder.py @ 0:520cba9a0d42

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Jun 2019 14:57:22 +0200
parents
children f1ebec09b120
comparison
equal deleted inserted replaced
-1:000000000000 0:520cba9a0d42
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://bitbucket.org/sjodogne/orthanc/raw'
16
17 FILES = [
18 'DownloadOrthancFramework.cmake',
19 ]
20
21 SDK = [
22 'orthanc/OrthancCPlugin.h',
23 ]
24
25
26 def Download(x):
27 branch = x[0]
28 source = x[1]
29 target = os.path.join(TARGET, x[2])
30 print(target)
31
32 try:
33 os.makedirs(os.path.dirname(target))
34 except:
35 pass
36
37 url = '%s/%s/%s' % (REPOSITORY, branch, source)
38
39 with open(target, 'w') as f:
40 f.write(urllib2.urlopen(url).read())
41
42
43 commands = []
44
45 for f in FILES:
46 commands.append([ 'default',
47 os.path.join('Resources', f),
48 f ])
49
50 for f in SDK:
51 commands.append([
52 'Orthanc-%s' % PLUGIN_SDK_VERSION,
53 'Plugins/Include/%s' % f,
54 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f)
55 ])
56
57
58 pool = multiprocessing.Pool(10) # simultaneous downloads
59 pool.map(Download, commands)