diff --git a/src/plant_transaction_data/__pycache__/service.cpython-311.pyc b/src/plant_transaction_data/__pycache__/service.cpython-311.pyc index 51e02e3..323bc82 100644 Binary files a/src/plant_transaction_data/__pycache__/service.cpython-311.pyc and b/src/plant_transaction_data/__pycache__/service.cpython-311.pyc differ diff --git a/src/plant_transaction_data/service.py b/src/plant_transaction_data/service.py index fd7dfc6..5963534 100644 --- a/src/plant_transaction_data/service.py +++ b/src/plant_transaction_data/service.py @@ -141,6 +141,29 @@ async def update( await db_session.commit() + # Get the directory of the current file + # directory_path = "../modules/plant" + directory_path = os.path.abspath( + os.path.join(os.path.dirname(__file__), "../modules/plant") + ) + + # Construct path to the script + script_path = os.path.join(directory_path, "run.py") + + try: + process = await asyncio.create_subprocess_exec( + "python", script_path, stdout=PIPE, stderr=PIPE, cwd=directory_path + ) + stdout, stderr = await process.communicate() + + # Check if the script executed successfully + if process.returncode != 0: + print(f"Script execution error: {stderr.decode()}") + else: + print(f"Script output: {stdout.decode()}") + except Exception as e: + print(f"Error executing script: {e}") + return transaction_data