feat: add prediction to update unit transaction API

main
MrWaradana 12 months ago
parent 0e4be2d20f
commit 31e3c5c7ed

@ -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

Loading…
Cancel
Save