comparison GenerateConfigurationForTests.py @ 101:71bca28a4645

remove the dependency upon installing Orthanc to generate the default configuration file
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 Feb 2017 15:56:34 +0100
parents 2af6c0fb850d
children 50cd127e5330
comparison
equal deleted inserted replaced
100:2af6c0fb850d 101:71bca28a4645
24 import re 24 import re
25 import socket 25 import socket
26 import subprocess 26 import subprocess
27 import sys 27 import sys
28 import json 28 import json
29 import urllib
30
29 31
30 ## 32 ##
31 ## Parse the command-line arguments 33 ## Parse the command-line arguments
32 ## 34 ##
33 35
74 76
75 77
76 # Retrieve the IP address of the localhost 78 # Retrieve the IP address of the localhost
77 ip = socket.gethostbyname(socket.gethostname()) 79 ip = socket.gethostbyname(socket.gethostname())
78 80
79 subprocess.check_call([ 'Orthanc', '--config=%s' % args.target ]) 81
82 # Download the content of the default configuration file
83 with open(args.target, 'w') as f:
84 url = 'https://bitbucket.org/sjodogne/orthanc/raw/Orthanc-1.2.0/Resources/Configuration.json'
85 http = urllib.urlopen(url)
86 if http.getcode() != 200:
87 raise Exception('Cannot download: %s' % url)
88
89 f.write(http.read())
90
80 91
81 with open(args.target, 'r') as f: 92 with open(args.target, 'r') as f:
82 # Remove the C++-style comments 93 # Remove the C++-style comments
83 nocomment = re.sub('//.*$', '', f.read(), 0, re.MULTILINE) 94 nocomment = re.sub('//.*$', '', f.read(), 0, re.MULTILINE)
84 95