diff 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
line wrap: on
line diff
--- a/Resources/SyncOrthancFolder.py	Sat Apr 15 13:49:53 2023 +0200
+++ b/Resources/SyncOrthancFolder.py	Sat Apr 15 13:58:16 2023 +0200
@@ -8,7 +8,12 @@
 import multiprocessing
 import os
 import stat
-import urllib2
+import sys
+
+if sys.version_info[0] < 3:
+    from urllib2 import urlopen
+else:
+    from urllib.request import urlopen
 
 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
 PLUGIN_SDK_VERSION_OLD = [ '0.9.5', '1.4.0', '1.5.2', '1.5.4' ]
@@ -55,7 +60,7 @@
     branch = x[0]
     source = x[1]
     target = os.path.join(TARGET, x[2])
-    print target
+    print(target)
 
     try:
         os.makedirs(os.path.dirname(target))
@@ -65,8 +70,8 @@
     url = '%s/%s/%s' % (REPOSITORY, branch, source)
 
     try:
-        with open(target, 'w') as f:
-            f.write(urllib2.urlopen(url).read())
+        with open(target, 'wb') as f:
+            f.write(urlopen(url).read())
     except Exception as e:
         raise Exception('Cannot download: %s' % url)