From e3744e5b568bb3f2e61e5ff04e61d51657621300 Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Mon, 7 Nov 2022 12:53:26 +0100 Subject: [PATCH] XMLify rssi --- app.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 57b1bd8..5661668 100755 --- a/app.py +++ b/app.py @@ -60,7 +60,14 @@ def allowed_ext(filename): # Split from right at first dot to find ext and allow files with "." in name if filename.rsplit(".",1)[-1] in media_exts: return True - +def XMLify(string, child_node_name="child"): + ''' + ''' + root_element = "root" + if debug: + print("<{0}><{1}>{2}".format(root_element, child_node_name, string)) + return "<{0}><{1}>{2}".format(root_element, child_node_name, string) + def get_RSSI(): ''' Get wireless signal level to AP @@ -72,7 +79,7 @@ def get_RSSI(): rssi_signal = last_line.split(' ')[3][:-1].strip("-").strip("\n") if debug: print(rssi_signal) - return rssi_signal + return XMLify(rssi_signal, child_node_name="rssi") def led_init(): ''' @@ -150,6 +157,7 @@ def shutdown(): @auth.login_required def upload_file(): if request.method == "POST": + # TODO : First check name/size of file to avoid uploading if already exists ? # Check if the post request has the file part if "file" not in request.files: return _("No file part: {}").format(str(request.files))