Mercurial > hg > orthanc-tests
annotate GenerateConfigurationForTests.py @ 59:84378ada15ab
test_decode_brainix_as_jpeg
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Nov 2015 09:56:47 +0100 |
parents | f2dcf96fec51 |
children | 97acfdf0dbce |
rev | line source |
---|---|
3 | 1 #!/usr/bin/python |
2 | |
3 # Orthanc - A Lightweight, RESTful DICOM Store | |
4 # Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics | |
5 # Department, University Hospital of Liege, Belgium | |
6 # | |
7 # This program is free software: you can redistribute it and/or | |
8 # modify it under the terms of the GNU General Public License as | |
9 # published by the Free Software Foundation, either version 3 of the | |
10 # License, or (at your option) any later version. | |
11 # | |
12 # This program is distributed in the hope that it will be useful, but | |
13 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 # General Public License for more details. | |
16 # | |
17 # You should have received a copy of the GNU General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 | |
21 import argparse | |
22 import os | |
23 import re | |
24 import socket | |
25 import subprocess | |
26 import sys | |
27 | |
28 ## | |
29 ## Parse the command-line arguments | |
30 ## | |
31 | |
32 parser = argparse.ArgumentParser(description = 'Generate the configuration file for the ' + | |
33 'instance of Orthanc to be checked against the integration tests.') | |
34 | |
35 parser.add_argument('--target', | |
36 default = 'IntegrationTestsConfiguration.json', | |
37 help = 'Configuration file to generate') | |
38 | |
39 parser.add_argument('--force', | |
40 help = 'Overwrite the file even if it already exists', | |
41 action = 'store_true') | |
42 | |
31 | 43 parser.add_argument('--plugins', |
44 help = 'Add a path to a folder containing plugins') | |
45 | |
3 | 46 args = parser.parse_args() |
47 | |
48 | |
49 ## | |
50 ## Check whether the file can be overwritten | |
51 ## | |
52 | |
53 if os.path.exists(args.target) and not args.force: | |
54 print(""" | |
55 WARNING: The file %s will be overwritten! | |
56 | |
57 Are you sure ["yes" to go on]?""" % args.target) | |
58 | |
59 if sys.stdin.readline().strip() != 'yes': | |
60 print('Aborting...') | |
61 exit(0) | |
62 | |
63 | |
64 ## | |
65 ## Generate the configuration file | |
66 ## | |
67 | |
68 | |
69 # Retrieve the IP address of the localhost | |
70 ip = socket.gethostbyname(socket.gethostname()) | |
71 | |
72 subprocess.check_call([ 'Orthanc', '--config=%s' % args.target ]) | |
73 | |
74 with open(args.target, 'r') as f: | |
75 config = f.read() | |
76 | |
77 config = re.sub(r'("DicomAet"\s*:)\s*".*?"', r'\1 "ORTHANC"', config) | |
78 config = re.sub(r'("RemoteAccessAllowed"\s*:)\s*false', r'\1 true', config) | |
79 config = re.sub(r'("AuthenticationEnabled"\s*:)\s*false', r'\1 true', config) | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
13
diff
changeset
|
80 config = re.sub(r'("DicomAssociationCloseDelay"\s*:)\s*[0-9]*', r'\1 0', config) |
22 | 81 config = re.sub(r'("DefaultEncoding"\s*:)\s*".*?"', r'\1 "Windows1251"', config) # For test_issue_32 |
3 | 82 config = re.sub(r'("RegisteredUsers"\s*:)\s*{', r'\1 { "alice" : "orthanctest"', config) |
11 | 83 config = re.sub(r'("DicomModalities"\s*:)\s*{', r'\1 { "orthanctest" : [ "%s", "%s", %d ]' % |
3 | 84 ('ORTHANCTEST', ip, 5001), config) |
11 | 85 config = re.sub(r'("OrthancPeers"\s*:)\s*{', r'\1 { "peer" : [ "http://%s:%d/", "%s", "%s" ]' % |
86 (ip, 5000, 'alice', 'orthanctest'), config) | |
35 | 87 config = re.sub(r'("HttpCompressionEnabled"\s*:)\s*true', r'\1 false', config) |
3 | 88 |
13 | 89 # Enable case-insensitive PN (the default on versions <= 0.8.6) |
90 config = re.sub(r'("CaseSensitivePN"\s*:)\s*true', r'\1 false', config) | |
91 | |
31 | 92 if args.plugins != None: |
93 config = re.sub(r'("Plugins"\s*:\s*\[)', r'\1 "%s"' % args.plugins, config) | |
94 | |
95 | |
3 | 96 with open(args.target, 'wt') as f: |
97 f.write(config) | |
98 |