Mercurial > hg > orthanc-transfers
annotate Resources/SyncOrthancFolder.py @ 10:c9e28e31262e
new option: MaxHttpRetries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 04 Mar 2019 15:26:49 +0100 |
parents | 151e29acbb13 |
children | 17f775299b4a |
rev | line source |
---|---|
0 | 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.4.2' ] | |
15 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw' | |
16 | |
17 FILES = [ | |
18 'DownloadOrthancFramework.cmake', | |
19 'LinuxStandardBaseToolchain.cmake', | |
20 'MinGW-W64-Toolchain32.cmake', | |
21 'MinGW-W64-Toolchain64.cmake', | |
22 'MinGWToolchain.cmake', | |
23 ] | |
24 | |
25 SDK = [ | |
26 'orthanc/OrthancCPlugin.h', | |
27 ] | |
28 | |
29 | |
30 def Download(x): | |
31 branch = x[0] | |
32 source = x[1] | |
33 target = os.path.join(TARGET, x[2]) | |
34 print target | |
35 | |
36 try: | |
37 os.makedirs(os.path.dirname(target)) | |
38 except: | |
39 pass | |
40 | |
41 url = '%s/%s/%s' % (REPOSITORY, branch, source) | |
42 | |
43 with open(target, 'w') as f: | |
44 f.write(urllib2.urlopen(url).read()) | |
45 | |
46 | |
47 commands = [] | |
48 | |
49 for f in FILES: | |
50 commands.append([ 'default', | |
51 os.path.join('Resources', f), | |
52 f ]) | |
53 | |
7
151e29acbb13
use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
54 for version in PLUGIN_SDK_VERSION: |
151e29acbb13
use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
55 for f in SDK: |
151e29acbb13
use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
56 commands.append([ |
151e29acbb13
use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
57 'Orthanc-%s' % version, |
151e29acbb13
use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
58 'Plugins/Include/%s' % f, |
151e29acbb13
use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
59 'Sdk-%s/%s' % (version, f) |
151e29acbb13
use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
60 ]) |
0 | 61 |
62 | |
63 pool = multiprocessing.Pool(10) # simultaneous downloads | |
64 pool.map(Download, commands) |