mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-12 15:32:13 +02:00
better error messageS
This commit is contained in:
parent
a85ad6cd84
commit
c0ae090be0
@ -96,7 +96,7 @@ def testZmqHeadetTypeCount(name, num_mods, num_frames, fp):
|
||||
msg = f"Expected {expected_count} '{htype}' entries, found {htype_counts[htype]}"
|
||||
raise RuntimeException(msg)
|
||||
except Exception as e:
|
||||
raise RuntimeException(f'Failed to get zmq header count type. Error:{e}')
|
||||
raise RuntimeException(f'Failed to get zmq header count type. Error:{str(e)}') from e
|
||||
|
||||
Log(LogLevel.INFOGREEN, f"Zmq Header type count test passed for {name}")
|
||||
Log(LogLevel.INFOGREEN, f"Zmq Header type count test passed for {name}", fp)
|
||||
@ -117,7 +117,7 @@ def startTestsForAll(args, fp):
|
||||
testZmqHeadetTypeCount(server, args.num_mods, args.num_frames, fp)
|
||||
Log(LogLevel.INFO, '\n')
|
||||
except Exception as e:
|
||||
raise RuntimeException(f'Synchronizer Tests failed')
|
||||
raise RuntimeException(f'Synchronizer Tests failed') from e
|
||||
|
||||
Log(LogLevel.INFOGREEN, 'Passed all synchronizer tests for all detectors \n' + str(args.servers))
|
||||
|
||||
|
@ -65,7 +65,7 @@ def startCmdTestsForAll(args, fp):
|
||||
loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, fp=fp, num_mods=num_mods)
|
||||
runProcessWithLogFile('Cmd Tests for ' + server, cmd, fp, fname)
|
||||
except Exception as e:
|
||||
raise RuntimeException(f'Cmd Tests failed for {server}.')
|
||||
raise RuntimeException(f'Cmd Tests failed for {server}.') from e
|
||||
|
||||
Log(LogLevel.INFOGREEN, 'Passed all tests for all detectors \n' + str(args.servers))
|
||||
|
||||
|
@ -71,7 +71,7 @@ def killProcess(name, fp):
|
||||
if p.returncode != 0 and bool(checkIfProcessRunning(name)):
|
||||
raise RuntimeException(f"Could not kill {name} with pid {pid}")
|
||||
except Exception as e:
|
||||
raise RuntimeException(f"Failed to kill process {name} pid:{pid}. Exception occured: [code:{e}, msg:{e.stderr}]")
|
||||
raise RuntimeException(f"Failed to kill process {name} pid:{pid}. Error: {str(e)}]") from e
|
||||
#else:
|
||||
# Log(LogLevel.INFO, 'process not running : ' + name)
|
||||
|
||||
@ -101,7 +101,7 @@ def startProcessInBackground(cmd, fp):
|
||||
try:
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, restore_signals=False)
|
||||
except Exception as e:
|
||||
raise RuntimeException(f'Failed to start {cmd}:{e}')
|
||||
raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e
|
||||
|
||||
|
||||
def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name):
|
||||
@ -111,7 +111,7 @@ def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name):
|
||||
with open(log_file_name, 'w') as log_fp:
|
||||
subprocess.Popen(cmd, stdout=log_fp, stderr=log_fp, text=True)
|
||||
except Exception as e:
|
||||
raise RuntimeException(f'Failed to start {cmd}:{e}')
|
||||
raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e
|
||||
|
||||
|
||||
def runProcessWithLogFile(name, cmd, fp, log_file_name):
|
||||
@ -124,8 +124,8 @@ def runProcessWithLogFile(name, cmd, fp, log_file_name):
|
||||
except subprocess.CalledProcessError as e:
|
||||
pass
|
||||
except Exception as e:
|
||||
Log(LogLevel.ERROR, f'Failed to run {name}:{e}', fp)
|
||||
raise RuntimeException(f'Failed to run {name}:{e}')
|
||||
Log(LogLevel.ERROR, f'Failed to run {name}:{str(e)}', fp)
|
||||
raise RuntimeException(f'Failed to run {name}:{str(e)}')
|
||||
|
||||
with open (log_file_name, 'r') as f:
|
||||
for line in f:
|
||||
@ -156,7 +156,7 @@ def connectToVirtualServers(name, num_mods):
|
||||
try:
|
||||
d = Detector()
|
||||
except Exception as e:
|
||||
raise RuntimeException(f'Could not create Detector object for {name}. Error: {str(e)}')
|
||||
raise RuntimeException(f'Could not create Detector object for {name}. Error: {str(e)}') from e
|
||||
|
||||
counts_sec = 5
|
||||
while (counts_sec != 0):
|
||||
@ -205,7 +205,7 @@ def loadConfig(name, rx_hostname, settingsdir, fp, num_mods = 1, num_frames = 1)
|
||||
|
||||
d.frames = num_frames
|
||||
except Exception as e:
|
||||
raise RuntimeException(f'Could not load config for {name}. Error: {str(e)}')
|
||||
raise RuntimeException(f'Could not load config for {name}. Error: {str(e)}') from e
|
||||
|
||||
|
||||
def ParseArguments(description, default_num_mods=1):
|
||||
|
Loading…
x
Reference in New Issue
Block a user