Recent fixes to the TAUPI script + upload logic
This commit is contained in:
@@ -7,6 +7,15 @@ def upload(ip, script_id, code_file):
|
||||
with open(code_file, 'r', encoding='utf-8') as f:
|
||||
code = f.read()
|
||||
|
||||
import re
|
||||
# Remove comments and whitespace to save Shelly RAM
|
||||
# Remove multi-line comments
|
||||
code = re.sub(r'/\*.*?\*/', '', code, flags=re.DOTALL)
|
||||
# Remove single-line comments (ignoring http:// or https://)
|
||||
code = re.sub(r'(?<!:)\/\/.*', '', code)
|
||||
# Strip leading/trailing whitespace and drop empty lines
|
||||
code = '\n'.join([line.strip() for line in code.split('\n') if line.strip()])
|
||||
|
||||
url = f"http://{ip}/rpc"
|
||||
|
||||
# Stop the script first to prevent write locks
|
||||
|
||||
Reference in New Issue
Block a user