mirror of
https://github.com/thiagoralves/OpenPLC_v3.git
synced 2026-09-25 00:42:46 +08:00
[RTOP-26] catch errors on file upload and compile program
This commit is contained in:
@@ -137,9 +137,9 @@ class runtime:
|
||||
|
||||
else:
|
||||
# No debug info... probably a program generated from the old editor. Use the blank debug info just to compile the program
|
||||
f = open('./core/debug.blank', "r")
|
||||
c_debug = f.read()
|
||||
f.close()
|
||||
with open('./core/debug.blank', "r") as f:
|
||||
c_debug = f.read()
|
||||
f.close()
|
||||
|
||||
# Write c_debug file
|
||||
with open('./core/debug.cpp', "w") as f:
|
||||
|
||||
@@ -59,11 +59,17 @@ def restapi_callback_get(argument: str, data: dict) -> dict:
|
||||
|
||||
elif argument == "compilation-status":
|
||||
status = openplc_runtime.compilation_status_str
|
||||
if status == "":
|
||||
return {"compilation-status": "No compilation in progress"}
|
||||
return {"compilation-status": status}
|
||||
|
||||
elif argument == "compilation-logs":
|
||||
logs = openplc_runtime.compilation_status()
|
||||
return {"compilation-logs": logs}
|
||||
try:
|
||||
logs = openplc_runtime.compilation_status()
|
||||
return {"compilation-logs": logs}
|
||||
except Exception as e:
|
||||
logger.error(f"Error retrieving compilation logs: {e}")
|
||||
return {"error": str(e)}
|
||||
|
||||
elif argument == "status":
|
||||
return {"current_status": "operational", "details": data}
|
||||
|
||||
Reference in New Issue
Block a user