diff 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
line wrap: on
line diff
--- a/OrthancStone/Resources/SyncOrthancFolder.py	Wed Nov 02 14:56:35 2022 +0100
+++ b/OrthancStone/Resources/SyncOrthancFolder.py	Wed Nov 02 15:07:06 2022 +0100
@@ -29,7 +29,13 @@
 import multiprocessing
 import os
 import stat
-import urllib2
+import sys
+
+if sys.version_info[0] < 3:
+    from urllib import urlopen
+else:
+    from urllib.request import urlopen
+
 
 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file'
@@ -54,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))
@@ -63,8 +69,8 @@
 
     url = '%s/%s/%s' % (REPOSITORY, branch, source)
 
-    with open(target, 'w') as f:
-        f.write(urllib2.urlopen(url).read())
+    with open(target, 'wb') as f:
+        f.write(urlopen(url).read())
 
 
 commands = []