From 85854e95a4207ef6c91890d26c2969a97e178832 Mon Sep 17 00:00:00 2001 From: Felix Zumstein Date: Wed, 6 Nov 2024 21:54:20 -0300 Subject: [PATCH] wip --- app/custom_scripts/examples.py | 4 ++++ app/routers/xlwings.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/custom_scripts/examples.py b/app/custom_scripts/examples.py index 9af681f..5650933 100644 --- a/app/custom_scripts/examples.py +++ b/app/custom_scripts/examples.py @@ -11,6 +11,10 @@ @script(target_cell="[xlwings_button]Sheet1!B4") def hello_world(book: xw.Book): + import time + + time.sleep(2) + print("xxxxxxxxxxxxxxxxxxxxxxxx") sheet = book.sheets.active cell = sheet["A1"] if cell.value == "Hello xlwings!": diff --git a/app/routers/xlwings.py b/app/routers/xlwings.py index cc1564b..cba6211 100644 --- a/app/routers/xlwings.py +++ b/app/routers/xlwings.py @@ -104,12 +104,15 @@ async def custom_functions_call( @router.post("/custom-scripts-call/{script_name}") async def custom_scripts_call(script_name: str, book: dep.Book, current_user: dep.User): logger.info(f"""Script "{script_name}" called by {current_user.name}""") + empty_book = book book = await xlwings.server.custom_scripts_call( custom_scripts, script_name, current_user, typehint_to_value={CurrentUser: current_user, xw.Book: book}, ) + if isinstance(book, dict): + return empty_book.json() return book.json()