comparison RenderingPlugin/Resources/SyncOrthancFolder.py @ 2004:6a96a1920fd8

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