changeset 520:a06d0a45c62f

Python 3 compatibility of GenerateConfigurationForTests.py
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Apr 2023 10:48:04 +0200
parents b1991073e4d1
children 8114f67e0f7f
files GenerateConfigurationForTests.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/GenerateConfigurationForTests.py	Thu Apr 06 17:01:27 2023 +0200
+++ b/GenerateConfigurationForTests.py	Fri Apr 07 10:48:04 2023 +0200
@@ -27,7 +27,12 @@
 import subprocess
 import sys
 import json
-import urllib
+import sys
+
+if sys.version_info[0] < 3:
+    from urllib2 import urlopen
+else:
+    from urllib.request import urlopen
 
 
 ##
@@ -85,11 +90,11 @@
 
 
 # Download the content of the default configuration file
-with open(args.target, 'w') as f:
+with open(args.target, 'wb') as f:
     url = 'https://hg.orthanc-server.com/orthanc/raw-file/default/OrthancServer/Resources/Configuration.json'
     #url = 'https://hg.orthanc-server.com/orthanc/raw-file/default/Resources/Configuration.json'
     #url = 'https://bitbucket.org/sjodogne/orthanc/raw/default/Resources/Configuration.json'
-    http = urllib.urlopen(url)
+    http = urlopen(url)
     if http.getcode() != 200:
         raise Exception('Cannot download: %s' % url)