From 703083fa66db8d9b7834b6f5b95e3128bdc3edd1 Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Tue, 18 Oct 2022 19:54:18 +0200 Subject: [PATCH] Empty playlist now reflects on timeline, fix file sync CA path --- app.py | 12 ++---------- docker-compose.yml | 24 +++++++++++++++++++++++- static/script.js | 14 ++++++++++++-- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index f7ca102..4f4e647 100755 --- a/app.py +++ b/app.py @@ -85,7 +85,6 @@ def isup(host_l, port): import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if useSSL: - #sslcontext = ssl.create_default_context(cafile=host_l + ".crt") sslcontext = ssl.create_default_context() if os.path.exists(CAfile): sslcontext.load_verify_locations(cafile=CAfile) @@ -101,7 +100,7 @@ def isup(host_l, port): return 1 except (socket.error, socket.timeout) as e: if DEBUG: - print("Error on connect to " + host_l + ": %s" % e) + print("Error on connect to " + host_l + ":" + str(port) + ": %s" % e) return 0 finally: s.close() @@ -136,8 +135,7 @@ def httpUpload(filename, hostl, trailing_slash=1): filename = "/" + filename files = { "file":( filename, open( media_folder_local + filename, "rb"), "multipart/form-data") } print(files) - # ~ resp = requests.post(url, files=files, auth=('', auth ), verify=hostl + ".crt") - resp = requests.post(url, files=files, headers=headers, verify=hostl + ".crt") + resp = requests.post(url, files=files, headers=headers, verify=CAfile) print(resp.text) if resp.ok: return 1 @@ -203,7 +201,6 @@ def sec2min(duration): # VLC lua utilities def sendCommand(host, arg0, arg1, arg2): - #conn = http.client.HTTPConnection( host + ":" + str(port), timeout=3 ) portl = port # Build request req = "/requests/status.xml" @@ -233,20 +230,16 @@ def sendCommand(host, arg0, arg1, arg2): req = req + "&input=file://" + media_folder_remote + "/" + arg1 # Send request if useSSL: - #sslcontext = ssl.create_default_context(cafile=host_l + ".crt") sslcontext = ssl.create_default_context() if os.path.exists(CAfile): sslcontext.load_verify_locations(cafile=CAfile) else: sslcontext.check_hostname = False sslcontext.verify_mode = ssl.CERT_NONE - # ~ if useSSL: - # ~ sslcontext = ssl.create_default_context(cafile=host + ".crt") conn = http.client.HTTPSConnection( host + ":" + str(portl), timeout=3, context = sslcontext ) else: conn = http.client.HTTPConnection( host + ":" + str(portl), timeout=3 ) try: - # ~ conn.request( "GET", req, headers={"Authorization":"Basic " + auth} ) conn.request( "GET", req, headers = headers ) except: return "Connection to " + host + " was refused on port " + str(portl) @@ -366,7 +359,6 @@ def sync(host): def action(host, arg0, arg1, arg2): status_message = "Idle" if arg0 not in cmd: - # ~ return "

Wrong command

" status_message = "

Wrong command

" elif host == "all": resp = [] diff --git a/docker-compose.yml b/docker-compose.yml index 201f1ce..3f6bb18 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,29 @@ services: # add dockerfile: Dockerfile ports: - "8080:8080" - command: "sh -c 'pip install -r requirements.txt && python app.py'" + - "8887:8887" + - "8888:8888" + #~ command: "sh -c 'sleep 3600'" + command: "sh -c 'pip install -r requirements.txt && sleep 3600'" volumes: - .:/app - ../medias:/medias + networks: + - dockervlan + +networks: + dockervlan: + name: dockervlan + driver: macvlan + driver_opts: + parent: wlo1 + ipam: + config: + - subnet: "10.42.0.1/24" + ip_range: "10.42.0.1/26" + gateway: "10.42.0.1" +#~ docker network create -d macvlan \ + #~ --subnet=10.42.0.1/24 \ + #~ --gateway=10.42.0.1 \ + #~ -o parent=wlo1 \ + #~ vpi-macvlan-net \ No newline at end of file diff --git a/static/script.js b/static/script.js index f96ba56..49af62a 100644 --- a/static/script.js +++ b/static/script.js @@ -129,7 +129,7 @@ addEventListener("DOMContentLoaded", function() { // On recupere la valeur de value="" sur le bouton var clickedButton = event.currentTarget; var command = clickedButton.value; - if (( command == "/10.42.0.135/reboot" ) || ( command == "/10.42.0.135/poweroff" )) { + if ( command.indexOf("/reboot" ) > -1 || command.indexOf("/poweroff") > -1 ) { if ( !confirm("Êtes vous certain de vouloir effectuer cette action ?") ) { return 0; } @@ -202,6 +202,14 @@ function parseResult(command, infos_array) { document.getElementById("playlist_"+infos_array[i].host).innerHTML = infos_array[i].leng + " item(s) in playlist - " + infos_array[i].duration; // Build html table and timeline var items_array = Array.from(infos_array[i].items); + console.log(items_array.length); + if (items_array.length == 0){ + var child_list = Array.from(document.getElementById("timeline").children); + for(i=0,l=child_list.length;i" + "Id" + @@ -222,9 +230,11 @@ function parseResult(command, infos_array) { addAttr("timeline", "length", len); if ( len < items_array.length ) { document.getElementById("timeline").appendChild( addElement("div", tl_cont_attr, 0, len) ); - } + } document.getElementById(tl_cont_attr.id + j).replaceChildren(child_node); + // Adjust elements width adjustTl(); + // Highlight currently playing element if (item_meta[3] != ""){ document.getElementById(tl_cont_attr.id + j).children[0].style.borderBottom = "4px solid " + timeline_color_cursor; document.getElementById(tl_cont_attr.id + j).children[0].style.fontWeight = "bold";