comparison OrthancStone/Resources/SyncOrthancFolder.py @ 2002:1bb0a9716876

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 02 Nov 2022 15:07:06 +0100
parents 7053b8a0aaec
children 6a96a1920fd8
comparison
equal deleted inserted replaced
2001:e943a84da9ac 2002:1bb0a9716876
27 # 27 #
28 28
29 import multiprocessing 29 import multiprocessing
30 import os 30 import os
31 import stat 31 import stat
32 import urllib2 32 import sys
33
34 if sys.version_info[0] < 3:
35 from urllib import urlopen
36 else:
37 from urllib.request import urlopen
38
33 39
34 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') 40 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
35 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file' 41 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file'
36 42
37 FILES = [ 43 FILES = [
52 58
53 def Download(x): 59 def Download(x):
54 branch = x[0] 60 branch = x[0]
55 source = x[1] 61 source = x[1]
56 target = os.path.join(TARGET, x[2]) 62 target = os.path.join(TARGET, x[2])
57 print target 63 print(target)
58 64
59 try: 65 try:
60 os.makedirs(os.path.dirname(target)) 66 os.makedirs(os.path.dirname(target))
61 except: 67 except:
62 pass 68 pass
63 69
64 url = '%s/%s/%s' % (REPOSITORY, branch, source) 70 url = '%s/%s/%s' % (REPOSITORY, branch, source)
65 71
66 with open(target, 'w') as f: 72 with open(target, 'wb') as f:
67 f.write(urllib2.urlopen(url).read()) 73 f.write(urlopen(url).read())
68 74
69 75
70 commands = [] 76 commands = []
71 77
72 for f in FILES: 78 for f in FILES: