mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-05 17:40:40 +02:00
raise an exception if the pull socket python script had errors at startup (for eg if pyzmq was not installed)
This commit is contained in:
parent
d0a946a919
commit
f40dc00757
@ -20,6 +20,7 @@ from utils_for_test import (
|
|||||||
cleanSharedmemory,
|
cleanSharedmemory,
|
||||||
startProcessInBackground,
|
startProcessInBackground,
|
||||||
startProcessInBackgroundWithLogFile,
|
startProcessInBackgroundWithLogFile,
|
||||||
|
checkLogForErrors,
|
||||||
startDetectorVirtualServer,
|
startDetectorVirtualServer,
|
||||||
loadConfig,
|
loadConfig,
|
||||||
ParseArguments
|
ParseArguments
|
||||||
@ -34,6 +35,9 @@ def startFrameSynchronizerPullSocket(name, fp):
|
|||||||
fname = PULL_SOCKET_PREFIX_FNAME + name + '.txt'
|
fname = PULL_SOCKET_PREFIX_FNAME + name + '.txt'
|
||||||
cmd = ['python', '-u', 'frameSynchronizerPullSocket.py']
|
cmd = ['python', '-u', 'frameSynchronizerPullSocket.py']
|
||||||
startProcessInBackgroundWithLogFile(cmd, fp, fname)
|
startProcessInBackgroundWithLogFile(cmd, fp, fname)
|
||||||
|
time.sleep(1)
|
||||||
|
checkLogForErrors(fp, fname)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def startFrameSynchronizer(num_mods, fp):
|
def startFrameSynchronizer(num_mods, fp):
|
||||||
|
@ -104,7 +104,7 @@ def startProcessInBackground(cmd, fp):
|
|||||||
raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e
|
raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e
|
||||||
|
|
||||||
|
|
||||||
def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name):
|
def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name: str):
|
||||||
Log(LogLevel.INFOBLUE, 'Starting up ' + ' '.join(cmd) + '. Log: ' + log_file_name)
|
Log(LogLevel.INFOBLUE, 'Starting up ' + ' '.join(cmd) + '. Log: ' + log_file_name)
|
||||||
Log(LogLevel.INFOBLUE, 'Starting up ' + ' '.join(cmd) + '. Log: ' + log_file_name, fp)
|
Log(LogLevel.INFOBLUE, 'Starting up ' + ' '.join(cmd) + '. Log: ' + log_file_name, fp)
|
||||||
try:
|
try:
|
||||||
@ -114,6 +114,22 @@ def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name):
|
|||||||
raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e
|
raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e
|
||||||
|
|
||||||
|
|
||||||
|
def checkLogForErrors(fp, log_file_path: str):
|
||||||
|
try:
|
||||||
|
with open(log_file_path, 'r') as log_file:
|
||||||
|
for line in log_file:
|
||||||
|
if 'Error' in line:
|
||||||
|
Log(LogLevel.ERROR, f"Error found in log: {line.strip()}")
|
||||||
|
Log(LogLevel.ERROR, f"Error found in log: {line.strip()}", fp)
|
||||||
|
raise RuntimeException("Error found in log file")
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"Log file not found: {log_file_path}")
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Exception while reading log: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def runProcessWithLogFile(name, cmd, fp, log_file_name):
|
def runProcessWithLogFile(name, cmd, fp, log_file_name):
|
||||||
Log(LogLevel.INFOBLUE, 'Running ' + name + '. Log: ' + log_file_name)
|
Log(LogLevel.INFOBLUE, 'Running ' + name + '. Log: ' + log_file_name)
|
||||||
Log(LogLevel.INFOBLUE, 'Running ' + name + '. Log: ' + log_file_name, fp)
|
Log(LogLevel.INFOBLUE, 'Running ' + name + '. Log: ' + log_file_name, fp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user