Fix calling log function

This commit is contained in:
Himadri Bhattacharjee
2023-03-24 10:25:12 +05:30
parent dd89db17bf
commit 1c08c9e710
3 changed files with 9 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import logs
import os
import json
from ducky import run_script_file
from ducky import run_script_file, run_script
def create(path, contents=b""):
@@ -31,4 +31,7 @@ def handle(body, response):
elif action == "create":
create(filename)
elif action == "run":
run_script_file(path)
if filename is not None:
run_script_file(path)
elif contents := body["contents"]:
run_script(contents)

View File

@@ -66,7 +66,7 @@ def run_script(contents):
millis = default_delay
delay(millis)
elif message := after("PRINT"):
log(message, logs)
log(message)
elif path := after("IMPORT"):
run_script_file(path)
elif millis := after("DEFAULT_DELAY", "DEFAULTDELAY"):
@@ -87,4 +87,4 @@ def run_script_file(path: str):
with open(path, "r", encoding="utf-8") as handle:
run_script(handle.read())
except OSError as e:
log(f"unable to open file {path}: {e}")
log(f"warning: unable to open file {path}: {e}")

View File

@@ -93,6 +93,8 @@ documents_icon.addEventListener('click', () => {
run_icon.addEventListener('click', () => {
if (title.value != "") {
doApi({"action": "run", "filename": title.value})
} else {
doApi({"action": "run", "contents": editor.value})
}
})