Recent fixes to the TAUPI script + upload logic

This commit is contained in:
Moritz Graf
2026-07-05 07:45:37 +02:00
parent a623ec7b85
commit e6556e5eb2
2 changed files with 32 additions and 24 deletions
+9
View File
@@ -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