XMLify rssi

This commit is contained in:
ABelliqueux 2022-11-07 12:53:26 +01:00
parent 8ffa1bd0e3
commit e3744e5b56
1 changed files with 10 additions and 2 deletions

10
app.py
View File

@ -60,6 +60,13 @@ def allowed_ext(filename):
# Split from right at first dot to find ext and allow files with "." in name # Split from right at first dot to find ext and allow files with "." in name
if filename.rsplit(".",1)[-1] in media_exts: if filename.rsplit(".",1)[-1] in media_exts:
return True return True
def XMLify(string, child_node_name="child"):
'''
'''
root_element = "root"
if debug:
print("<{0}><{1}>{2}</{1}></{0}>".format(root_element, child_node_name, string))
return "<{0}><{1}>{2}</{1}></{0}>".format(root_element, child_node_name, string)
def get_RSSI(): def get_RSSI():
''' '''
@ -72,7 +79,7 @@ def get_RSSI():
rssi_signal = last_line.split(' ')[3][:-1].strip("-").strip("\n") rssi_signal = last_line.split(' ')[3][:-1].strip("-").strip("\n")
if debug: if debug:
print(rssi_signal) print(rssi_signal)
return rssi_signal return XMLify(rssi_signal, child_node_name="rssi")
def led_init(): def led_init():
''' '''
@ -150,6 +157,7 @@ def shutdown():
@auth.login_required @auth.login_required
def upload_file(): def upload_file():
if request.method == "POST": 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 # Check if the post request has the file part
if "file" not in request.files: if "file" not in request.files:
return _("No file part: {}").format(str(request.files)) return _("No file part: {}").format(str(request.files))