Commit 1231ca15 authored by Josef Brandt's avatar Josef Brandt

Merge branch 'tempBranch' into Tiling2Develop

parents fa8cd07f a7ee6752
......@@ -353,7 +353,6 @@ if __name__ == '__main__':
logging.critical(tbinfo)
from .errors import showErrorMessageAsWidget
showErrorMessageAsWidget(tbinfo)
sys.exit(1)
sys.excepthook = excepthook
......
......@@ -34,6 +34,7 @@ class TileSizeError(Exception):
def showErrorMessageAsWidget(errorMessage):
import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv) #an app is needed to create and show QWidgets..
QtWidgets.QMessageBox.critical(QtWidgets.QWidget(), 'Fatal Error', errorMessage)
......@@ -37,7 +37,7 @@ def setDefaultLoggingConfig(logger: logging.Logger):
"""
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.WARNING)
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
for handler in logger.handlers:
......
......@@ -41,10 +41,9 @@ def scan(path, sol, zpositions, grid, controlclass, dataqueue,
merge_mertens = cv2.createMergeMertens()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logger.addHandler(logging.FileHandler(logpath))
logger.info('starting new optical scan')
setDefaultLoggingConfig(logger)
logger.info('starting new optical scan')
try:
ramanctrl = controlclass(logger)
......
......@@ -63,25 +63,26 @@ class WITecCOM(RamanBase):
def tryFunctionThreeTimes():
success = False
for _ in range(3):
result = None
try:
comCallFunction(*args, **kwargs)
result = comCallFunction(*args, **kwargs)
success = True
break
except pythoncom.com_error:
sleep(1.)
return success
return success, result
comObj = args[0] #self is always passed as first argument
functionSucceeded = tryFunctionThreeTimes()
functionSucceeded, result = tryFunctionThreeTimes()
if not functionSucceeded:
comObj.disconnect()
sleep(1.)
comObj.connect()
functionSucceeded = tryFunctionThreeTimes()
functionSucceeded, result = tryFunctionThreeTimes()
if not functionSucceeded:
showErrorMessageAsWidget(f'Com error on function {comCallFunction.__name__}')
raise pythoncom.com_error
return result
return wrapper
CLSID = "{C45E77CE-3D66-489A-B5E2-159F443BD1AA}"
......
......@@ -70,7 +70,6 @@ def scan(ramanSettings, positions, controlclass, dataqueue, stopevent,
logpath=''):
if logpath != '':
logger = logging.getLogger('RamanScanLogger')
logger.setLevel(logging.INFO)
logger.addHandler(logging.FileHandler(logpath))
setDefaultLoggingConfig(logger)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment