-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadhoctesting.py
59 lines (44 loc) · 1.32 KB
/
adhoctesting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
## adHocTesting.py
# Primary Owner: Andrew Downie
from ClinicalAnalysisEngine.cautils import checkPythonVersion
from ClinicalAnalysisEngine.cautils import socketRequest
from ClinicalAnalysisEngine.cautils import parseCLA
import json
import sys
import os
testFolder = "Adhoctests"
###
### Check python version running this script
###
checkPythonVersion.ConfirmPythonVersion3()
###
### Get CLA args
###
host, port, testName = parseCLA.HostPortData("Testname")
###
### List test names
###
if(testName == ""):
print("\nYou must select a test, valid testnames are:")
for path, subdirs, files in os.walk(testFolder):
subPath = "/".join(path.split("/")[1:])
for name in files:
print("\t" + os.path.join(subPath, name))
print("\nExiting...\n")
quit()
###
### Load the selected test from the file with the coresponding name into a string
###
testFilePath = os.path.join(testFolder, testName)
try:
testFile = open(testFilePath, "r")
testJson = testFile.read()
except:
print("Error opening test file: " + testFilePath + ",\n\tquiting...\n")
quit()
###
### Send the json string, and wait for a response
###
result = socketRequest.JsonRequest(host, port, testJson)
print("\n\nResult from server:\n" + result)