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