fix: moved faillable statements into a try block

This commit is contained in:
2026-07-17 15:47:10 +08:00
parent d62a772faa
commit ec6cc78b85
+6 -7
View File
@@ -44,7 +44,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
except Exception as e: except Exception as e:
logger.critical('Unable to load starup page', exc_info=e) logger.critical('Unable to load starup page', exc_info=e)
return 2 return 2
try: try:
driver.switch_to.new_window('tab') driver.switch_to.new_window('tab')
driver.set_page_load_timeout(parameters['timeout']) driver.set_page_load_timeout(parameters['timeout'])
@@ -141,17 +141,16 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
except Exception as e: except Exception as e:
logger.critical('Unable to load input data', exc_info=e) logger.critical('Unable to load input data', exc_info=e)
return 6 return 6
try: try:
file = Path('template.xlsx').resolve() file = Path('template.xlsx').resolve()
template = openpyxl.load_workbook(file) template = openpyxl.load_workbook(file)
header = next(data)
source = template.active
output = BytesIO()
except Exception as e: except Exception as e:
logger.critical('Unable to load template excel', exc_info=e) logger.critical('Unable to load template excel', exc_info=e)
return 7 return 7
header = next(data, None)
source = template.active
output = BytesIO()
def preprocess(data: str): def preprocess(data: str):
try: return float(data) try: return float(data)
@@ -172,7 +171,7 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
source[coord] = value source[coord] = value
sheet = template.copy_worksheet(source) sheet = template.copy_worksheet(source)
sheet.title = 'Copy' sheet.title = "COPY"
logger.debug('%s', sheet.title) logger.debug('%s', sheet.title)
if not len(template.worksheets) > 1: if not len(template.worksheets) > 1: