diff GenerateConfigurationForTests.py @ 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 5dca7ef42156
children 6399d3a1cd30
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)