comparison GenerateConfigurationForTests.py @ 87:4b24faec842b

test_reconstruct_json2 + test_private_tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Nov 2016 17:42:39 +0100
parents 91e2ed032f96
children 47a3d6c08413
comparison
equal deleted inserted replaced
86:0401ef51f5c1 87:4b24faec842b
22 import os 22 import os
23 import re 23 import re
24 import socket 24 import socket
25 import subprocess 25 import subprocess
26 import sys 26 import sys
27 import json
27 28
28 ## 29 ##
29 ## Parse the command-line arguments 30 ## Parse the command-line arguments
30 ## 31 ##
31 32
75 ip = socket.gethostbyname(socket.gethostname()) 76 ip = socket.gethostbyname(socket.gethostname())
76 77
77 subprocess.check_call([ 'Orthanc', '--config=%s' % args.target ]) 78 subprocess.check_call([ 'Orthanc', '--config=%s' % args.target ])
78 79
79 with open(args.target, 'r') as f: 80 with open(args.target, 'r') as f:
80 config = f.read() 81 # Remove the C++-style comments
82 nocomment = re.sub('//.*$', '', f.read(), 0, re.MULTILINE)
81 83
82 config = re.sub(r'("DicomAet"\s*:)\s*".*?"', r'\1 "ORTHANC"', config) 84 # Remove the C-style comments
83 config = re.sub(r'("DicomPort"\s*:)\s*.*?,', r'\1 %d,' % args.dicom, config) 85 nocomment = re.sub('/\*.*?\*/', '', nocomment, 0, re.DOTALL | re.MULTILINE)
84 config = re.sub(r'("RemoteAccessAllowed"\s*:)\s*false', r'\1 true', config) 86
85 config = re.sub(r'("AuthenticationEnabled"\s*:)\s*false', r'\1 true', config) 87 config = json.loads(nocomment)
86 config = re.sub(r'("DicomAssociationCloseDelay"\s*:)\s*[0-9]*', r'\1 0', config) 88
87 config = re.sub(r'("DefaultEncoding"\s*:)\s*".*?"', r'\1 "Windows1251"', config) # For test_issue_32 89 config['AllowFindSopClassesInStudy'] = True
88 config = re.sub(r'("RegisteredUsers"\s*:)\s*{', r'\1 { "alice" : "orthanctest"', config) 90 config['AuthenticationEnabled'] = True
89 config = re.sub(r'("DicomModalities"\s*:)\s*{', r'\1 { "orthanctest" : [ "%s", "%s", %d ]' % 91 config['DefaultEncoding'] = 'Windows1251' # For test_issue_32
90 ('ORTHANCTEST', ip, 5001), config) 92 config['DicomAet'] = 'ORTHANC'
91 config = re.sub(r'("OrthancPeers"\s*:)\s*{', r'\1 { "peer" : [ "http://%s:%d/", "%s", "%s" ]' % 93 config['DicomAssociationCloseDelay'] = 0
92 (ip, 5000, 'alice', 'orthanctest'), config) 94 config['DicomModalities'] = { 'orthanctest' : [ 'ORTHANCTEST', ip, 5001 ] }
93 config = re.sub(r'("HttpCompressionEnabled"\s*:)\s*true', r'\1 false', config) 95 config['DicomPort'] = args.dicom
96 config['HttpCompressionEnabled'] = False
97 config['OrthancPeers'] = { 'peer' : [ 'http://%s:%d/' % (ip, 5000), 'alice', 'orthanctest' ] }
98 config['RegisteredUsers'] = { 'alice' : 'orthanctest' }
99 config['RemoteAccessAllowed'] = True
100 config['Dictionary'] = {
101 "00e1,10c2" : [ "UI", "PET-CT Multi Modality Name", 1, 1, "ELSCINT1" ],
102 "7053,1003" : [ "ST", "Original Image Filename", 1, 1, "Philips PET Private Group" ]
103 }
94 104
95 # Enable case-insensitive PN (the default on versions <= 0.8.6) 105 # Enable case-insensitive PN (the default on versions <= 0.8.6)
96 config = re.sub(r'("CaseSensitivePN"\s*:)\s*true', r'\1 false', config) 106 config['CaseSensitivePN'] = False
97
98 config = re.sub(r'("AllowFindSopClassesInStudy"\s*:)\s*false', r'\1 true', config)
99
100 107
101 if args.plugins != None: 108 if args.plugins != None:
102 config = re.sub(r'("Plugins"\s*:\s*\[)', r'\1 "%s"' % args.plugins, config) 109 config['Plugins'] = [ args.plugins ]
103
104 110
105 with open(args.target, 'wt') as f: 111 with open(args.target, 'wt') as f:
106 f.write(config) 112 f.write(json.dumps(config, indent = True, sort_keys = True))
107 113 f.write('\n')