comparison Resources/SyncOrthancFolder.py @ 407:ca6dc9bb8b79

integration db-protobuf->mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 15 Apr 2023 13:58:16 +0200
parents de6de66d70b2
children e25f4500b531
comparison
equal deleted inserted replaced
405:1938ba8fba35 407:ca6dc9bb8b79
6 # 6 #
7 7
8 import multiprocessing 8 import multiprocessing
9 import os 9 import os
10 import stat 10 import stat
11 import urllib2 11 import sys
12
13 if sys.version_info[0] < 3:
14 from urllib2 import urlopen
15 else:
16 from urllib.request import urlopen
12 17
13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') 18 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
14 PLUGIN_SDK_VERSION_OLD = [ '0.9.5', '1.4.0', '1.5.2', '1.5.4' ] 19 PLUGIN_SDK_VERSION_OLD = [ '0.9.5', '1.4.0', '1.5.2', '1.5.4' ]
15 PLUGIN_SDK_VERSION_NEW = [ '1.9.2', '1.12.0' ] 20 PLUGIN_SDK_VERSION_NEW = [ '1.9.2', '1.12.0' ]
16 HAS_PROTOCOL_BUFFERS = [ '1.12.0' ] 21 HAS_PROTOCOL_BUFFERS = [ '1.12.0' ]
53 58
54 def Download(x): 59 def Download(x):
55 branch = x[0] 60 branch = x[0]
56 source = x[1] 61 source = x[1]
57 target = os.path.join(TARGET, x[2]) 62 target = os.path.join(TARGET, x[2])
58 print target 63 print(target)
59 64
60 try: 65 try:
61 os.makedirs(os.path.dirname(target)) 66 os.makedirs(os.path.dirname(target))
62 except: 67 except:
63 pass 68 pass
64 69
65 url = '%s/%s/%s' % (REPOSITORY, branch, source) 70 url = '%s/%s/%s' % (REPOSITORY, branch, source)
66 71
67 try: 72 try:
68 with open(target, 'w') as f: 73 with open(target, 'wb') as f:
69 f.write(urllib2.urlopen(url).read()) 74 f.write(urlopen(url).read())
70 except Exception as e: 75 except Exception as e:
71 raise Exception('Cannot download: %s' % url) 76 raise Exception('Cannot download: %s' % url)
72 77
73 78
74 commands = [] 79 commands = []