Mercurial > hg > orthanc-tests
comparison 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 |
comparison
equal
deleted
inserted
replaced
519:b1991073e4d1 | 520:a06d0a45c62f |
---|---|
25 import re | 25 import re |
26 import socket | 26 import socket |
27 import subprocess | 27 import subprocess |
28 import sys | 28 import sys |
29 import json | 29 import json |
30 import urllib | 30 import sys |
31 | |
32 if sys.version_info[0] < 3: | |
33 from urllib2 import urlopen | |
34 else: | |
35 from urllib.request import urlopen | |
31 | 36 |
32 | 37 |
33 ## | 38 ## |
34 ## Parse the command-line arguments | 39 ## Parse the command-line arguments |
35 ## | 40 ## |
83 # Retrieve the IP address of the localhost | 88 # Retrieve the IP address of the localhost |
84 ip = socket.gethostbyname(socket.gethostname()) | 89 ip = socket.gethostbyname(socket.gethostname()) |
85 | 90 |
86 | 91 |
87 # Download the content of the default configuration file | 92 # Download the content of the default configuration file |
88 with open(args.target, 'w') as f: | 93 with open(args.target, 'wb') as f: |
89 url = 'https://hg.orthanc-server.com/orthanc/raw-file/default/OrthancServer/Resources/Configuration.json' | 94 url = 'https://hg.orthanc-server.com/orthanc/raw-file/default/OrthancServer/Resources/Configuration.json' |
90 #url = 'https://hg.orthanc-server.com/orthanc/raw-file/default/Resources/Configuration.json' | 95 #url = 'https://hg.orthanc-server.com/orthanc/raw-file/default/Resources/Configuration.json' |
91 #url = 'https://bitbucket.org/sjodogne/orthanc/raw/default/Resources/Configuration.json' | 96 #url = 'https://bitbucket.org/sjodogne/orthanc/raw/default/Resources/Configuration.json' |
92 http = urllib.urlopen(url) | 97 http = urlopen(url) |
93 if http.getcode() != 200: | 98 if http.getcode() != 200: |
94 raise Exception('Cannot download: %s' % url) | 99 raise Exception('Cannot download: %s' % url) |
95 | 100 |
96 f.write(http.read()) | 101 f.write(http.read()) |
97 | 102 |