mirror of
https://github.com/dbisu/pico-ducky.git
synced 2026-04-22 15:11:24 +00:00
@@ -1,5 +1,5 @@
|
||||
# License : GPLv2.0
|
||||
# copyright (c) 2023 Dave Bailey
|
||||
# copyright (c) 2026 Dave Bailey
|
||||
# Author: Dave Bailey (dbisu, @daveisu)
|
||||
#
|
||||
# TODO: ADD support for the following:
|
||||
@@ -298,7 +298,7 @@ async def parseLine(line, script_lines):
|
||||
print(f"Unknown key to RELEASE: <{key}>")
|
||||
elif(line[0:5] == "DELAY"):
|
||||
line = replaceVariables(line)
|
||||
time.sleep(float(line[6:])/1000)
|
||||
await asyncio.sleep(float(line[6:])/1000)
|
||||
elif line == "STRINGLN": #< stringLN block
|
||||
line = next(script_lines).strip()
|
||||
line = replaceVariables(line)
|
||||
@@ -495,7 +495,7 @@ async def runScript(file):
|
||||
for i in range(int(line[7:])):
|
||||
#repeat the last command
|
||||
parseLine(previousLine, script_lines)
|
||||
time.sleep(float(defaultDelay) / 1000)
|
||||
await asyncio.sleep(float(defaultDelay) / 1000)
|
||||
elif line.startswith("RESTART_PAYLOAD"):
|
||||
restart = True
|
||||
break
|
||||
@@ -505,7 +505,7 @@ async def runScript(file):
|
||||
else:
|
||||
await parseLine(line, script_lines)
|
||||
previousLine = line
|
||||
time.sleep(float(defaultDelay) / 1000)
|
||||
await asyncio.sleep(float(defaultDelay) / 1000)
|
||||
except OSError as e:
|
||||
print("Unable to open file", file)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import socketpool
|
||||
import time
|
||||
import os
|
||||
import storage
|
||||
import asyncio
|
||||
|
||||
import wsgiserver as server
|
||||
from adafruit_wsgi.wsgi_app import WSGIApp
|
||||
@@ -225,11 +226,11 @@ def delete(request, filename):
|
||||
return("200 OK",[('Content-Type', 'text/html')], response)
|
||||
|
||||
@web_app.route("/run/<filename>")
|
||||
def run_script(request, filename):
|
||||
async def run_script(request, filename):
|
||||
print("run_script ", filename)
|
||||
response = response_html.format("Running script " + filename)
|
||||
#print(response)
|
||||
runScript(filename)
|
||||
await runScript(filename)
|
||||
return("200 OK",[('Content-Type', 'text/html')], response)
|
||||
|
||||
@web_app.route("/")
|
||||
@@ -238,12 +239,12 @@ def index(request):
|
||||
return("200 OK", [('Content-Type', 'text/html')], response)
|
||||
|
||||
@web_app.route("/api/run/<filenumber>")
|
||||
def run_script(request, filenumber):
|
||||
async def run_script(request, filenumber):
|
||||
filename = setPayload(int(filenumber))
|
||||
print("run_script ", filenumber)
|
||||
response = response_html.format("Running script " + filename)
|
||||
#print(response)
|
||||
runScript(filename)
|
||||
await runScript(filename)
|
||||
return("200 OK",[('Content-Type', 'text/html')], response)
|
||||
|
||||
async def startWebService():
|
||||
|
||||
Reference in New Issue
Block a user