Add blink command
This commit is contained in:
parent
4131ddfb73
commit
1da4beb6ab
38
app.py
38
app.py
|
@ -25,7 +25,7 @@ hosts_available, hosts_unavailable = [],[]
|
|||
|
||||
# Map vlc cmds
|
||||
# See https://github.com/videolan/vlc/blob/1336447566c0190c42a1926464fa1ad2e59adc4f/share/lua/http/requests/README.txt
|
||||
cmd = {
|
||||
cmd_player = {
|
||||
"play" : "pl_play",
|
||||
"resume" : "pl_forceresume",
|
||||
"pause" : "pl_forcepause",
|
||||
|
@ -53,13 +53,15 @@ cmd = {
|
|||
#"key" : "key=",
|
||||
#"browse" : "browse.xml?uri=file://~"
|
||||
# System commands :
|
||||
"rssi" : "rssi",
|
||||
"blink" : "blink",
|
||||
"poweroff" : "poweroff",
|
||||
"reboot" : "reboot",
|
||||
# ~ "rssi" : "rssi",
|
||||
# ~ "blink" : "blink",
|
||||
# ~ "poweroff" : "poweroff",
|
||||
# ~ "reboot" : "reboot",
|
||||
|
||||
}
|
||||
|
||||
cmd_server = ["blink", "reboot", "poweroff", "rssi"]
|
||||
|
||||
# Set configuration
|
||||
|
||||
DEBUG = app.config['DEFAULT']['DEBUG']
|
||||
|
@ -137,9 +139,11 @@ def httpUpload(filename, hostl, trailing_slash=1):
|
|||
if not trailing_slash:
|
||||
filename = "/" + filename
|
||||
files = { "file":( filename, open( media_folder_local + filename, "rb"), "multipart/form-data") }
|
||||
print(files)
|
||||
if DEBUG:
|
||||
print(files)
|
||||
resp = requests.post(url, files=files, headers=headers, verify=CAfile)
|
||||
print(resp.text)
|
||||
if DEBUG:
|
||||
print(resp.text)
|
||||
if resp.ok:
|
||||
return 1
|
||||
else:
|
||||
|
@ -209,17 +213,11 @@ def sendCommand(host, arg0, arg1, arg2):
|
|||
req = "/requests/status.xml"
|
||||
if arg0 == "list" :
|
||||
req = "/requests/playlist.xml"
|
||||
elif arg0 == "rssi":
|
||||
req = "/rssi"
|
||||
portl = cmd_port
|
||||
elif arg0 == "reboot":
|
||||
req = "/reboot"
|
||||
portl = cmd_port
|
||||
elif arg0 == "poweroff":
|
||||
req = "/poweroff"
|
||||
elif arg0 in cmd_server:
|
||||
req = "/" + str(arg0)
|
||||
portl = cmd_port
|
||||
elif arg0 != "status" :
|
||||
req = req + "?command=" + cmd[arg0]
|
||||
req = req + "?command=" + cmd_player[arg0]
|
||||
if arg1 != "null" :
|
||||
if (arg0 == "play") or (arg0 == "delete") or (arg0 == "sort") or (arg0 == "move"):
|
||||
req = req + "&id=" + arg1
|
||||
|
@ -245,6 +243,7 @@ def sendCommand(host, arg0, arg1, arg2):
|
|||
try:
|
||||
conn.request( "GET", req, headers = headers )
|
||||
resp = conn.getresponse()
|
||||
data = resp.read()
|
||||
except http.client.HTTPException:
|
||||
print("Connection to " + host + " timed out")
|
||||
return "Connection to " + host + " timed out"
|
||||
|
@ -253,7 +252,7 @@ def sendCommand(host, arg0, arg1, arg2):
|
|||
finally:
|
||||
conn.close()
|
||||
# Parse response
|
||||
data = resp.read()
|
||||
# ~ data = resp.read()
|
||||
|
||||
if arg0 == "rssi":
|
||||
if DEBUG:
|
||||
|
@ -366,7 +365,7 @@ def sync(host):
|
|||
@app.route("/<host>/<arg0>/<arg1>/<arg2>")
|
||||
def action(host, arg0, arg1, arg2):
|
||||
status_message = "Idle"
|
||||
if arg0 not in cmd:
|
||||
if (arg0 not in cmd_player) and (arg0 not in cmd_server):
|
||||
status_message = "<p>Wrong command</p>"
|
||||
elif host == "all":
|
||||
resp = []
|
||||
|
@ -383,5 +382,4 @@ def action(host, arg0, arg1, arg2):
|
|||
|
||||
if __name__ == '__main__':
|
||||
# ~ app.run()
|
||||
#serve(app, host='127.0.0.1', port=8080)
|
||||
serve(app, host='0.0.0.0', port=8080)
|
||||
serve(app, host='127.0.0.1', port=8080)
|
|
@ -29,8 +29,8 @@ sha256 : 0fe3fe76d0e56e445124fa20646fa8b3d8c59568786b3ebc8a96d83d92f203e3
|
|||
* Webgui beautifying
|
||||
|
||||
## 0.4 : 2022-10-21-videopi.img.xz
|
||||
md5 : 2a54eb1763060db652c4c5d89c07ef2a
|
||||
sha256 : 10b65d5260222e4cdc591ad5384247cbc22d515dc55ea6b31b2daf0b6fd01004
|
||||
md5 : dee7af70135994169cab4f073ee51905
|
||||
sha256 : ec3e17fc9b41f8c5181484e9866be2d1d92cab8403210e3d22f4f689edd4cfde
|
||||
|
||||
* Switch to rpi os Bullseye
|
||||
* Switch to user 'pil', pw 'pilpoil'
|
||||
|
@ -53,6 +53,7 @@ sha256 : 10b65d5260222e4cdc591ad5384247cbc22d515dc55ea6b31b2daf0b6fd01004
|
|||
# DOING NEXT :
|
||||
* ~ Test with several rpis
|
||||
* Define http auth secret at setup
|
||||
* Increase live host scan when host first found
|
||||
|
||||
# DONE :
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ do
|
|||
# Change hostname
|
||||
echo "$HOST_NAME" | sudo tee "$ROOTFS_MOUNT/etc/hostname"
|
||||
# Reflect that in /etc/hosts
|
||||
sed -i "$ d" "$ROOTFS_MOUNT/etc/hosts"
|
||||
sudo sed -i "$ d" "$ROOTFS_MOUNT/etc/hosts"
|
||||
echo -e "127.0.1.1\t$HOST_NAME" | sudo tee -a "$ROOTFS_MOUNT/etc/hosts"
|
||||
## Enable SSH
|
||||
green "Operation 5/13 : Enabling SSH server on boot ...\n"
|
||||
|
@ -165,7 +165,7 @@ do
|
|||
if [ "$ADD_SSH_CONF" == "y" ]
|
||||
then
|
||||
# Add to ~/.ssh/config
|
||||
echo -e "Host $HOST_NAME\n\tHostName $HOST\n\tIdentityFile ~/.ssh/$HOST_NAME\n\tUser $PI_USER" | tee -a "$HOME/.ssh/config"
|
||||
echo -e "\nHost $HOST_NAME\n\tHostname $HOST\n\tIdentityFile ~/.ssh/$HOST_NAME\n\tUser $PI_USER" | tee -a "$HOME/.ssh/config"
|
||||
fi
|
||||
# Copy public key to rpi
|
||||
green "Operation 7/13 : Installing public SSH key $HOME/.ssh/$HOST.pub in $ROOTFS_MOUNT/home/$PI_USER/.ssh/authorized_keys...\n"
|
||||
|
@ -229,7 +229,7 @@ network={
|
|||
umount $BOOT_MOUNT
|
||||
umount $ROOTFS_MOUNT
|
||||
yellow "Client $(($IP-9))/$CLIENT_NUMBER done."
|
||||
if [ $(($IP+1)) -lt $(($CLIENT_NUMBER+$IP)) ]
|
||||
if [ $IP -le $IP_CNT ]
|
||||
then
|
||||
red "Please swap sd card in reader and enter uppercase 'yes' to proceed with next client :"
|
||||
read -n 4 GO_ON
|
||||
|
|
|
@ -10,7 +10,7 @@ media_exts = ["mp4", "avi", "mkv"]
|
|||
auth = "secret"
|
||||
# OnNlY3JldA==
|
||||
cmd_auth = "secret"
|
||||
hosts = ["10.42.0.135", "10.42.0.11"]
|
||||
hosts = ["10.42.0.10", "10.42.0.11"]
|
||||
# VLC http LUA port
|
||||
port = 8887
|
||||
# Clients cmd port
|
||||
|
|
|
@ -156,6 +156,16 @@ Host 10.42.0.135
|
|||
```
|
||||
|
||||
|
||||
## Sudoers : commandes systèmes sans mot de passe
|
||||
|
||||
`/etc/sudoers.d/010_pilpil_nopasswd.conf` :
|
||||
|
||||
```
|
||||
Cmnd_Alias PILPIL=/usr/sbin/reboot, /usr/sbin/poweroff, /usr/bin/tee
|
||||
pil ALL=(ALL) NOPASSWD: PILPIL
|
||||
```
|
||||
|
||||
|
||||
## Systemd Unit : démarrage automatique des services
|
||||
|
||||
## VLC
|
||||
|
|
|
@ -202,7 +202,7 @@ 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);
|
||||
//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<l;i++){
|
||||
|
@ -259,10 +259,10 @@ function parseResult(command, infos_array) {
|
|||
for ( var i=0, l=host_down.length; i<l; i++){
|
||||
document.getElementById(host_down[i]).style.display = 'none';
|
||||
}
|
||||
//~ if (host_up.length) {
|
||||
//~ scanInterval = 10000;
|
||||
//~ document.getElementById("status_all").innerHTML = "Scan intarvel set to " + scanInterval;
|
||||
//~ }
|
||||
if (host_up.length) {
|
||||
scanInterval = 10000;
|
||||
document.getElementById("status_all").innerHTML = "Scan intarvel set to " + scanInterval;
|
||||
}
|
||||
document.getElementById("status_all").innerHTML = host_up.length + " client(s) found.";
|
||||
break;
|
||||
case "/browse":
|
||||
|
@ -322,11 +322,5 @@ function sendCmd(command) {
|
|||
setInterval( sendCmd, 500, "/all/status");
|
||||
setInterval( sendCmd, 1000, "/all/list");
|
||||
setInterval( sendCmd, scanInterval, "/scan");
|
||||
setInterval( sendCmd, 10000, "/all/rssi");
|
||||
|
||||
|
||||
/* TODO :
|
||||
* Change scanInterval after first results are in (3 to 30 seconds)
|
||||
*
|
||||
*/
|
||||
setInterval( sendCmd, 20000, "/all/rssi");
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<button value="/all/enqueue/tst.mp4" class="command btn btn-block btn-lg btn-default" role="button">β<span class="btn_txt">tst.mp4</span></button>
|
||||
<button value="/all/enqueue/tst1.mp4" class="command btn btn-block btn-lg btn-default" role="button">β<span class="btn_txt">tst1.mp4</span></button>
|
||||
<button value="/all/enqueue/sangliers_1080.mp4" class="command btn btn-block btn-lg btn-default" role="button">β<span class="btn_txt">sangli.mp4</span></button>
|
||||
<button value="/move/0/1" class="command btn btn-block btn-lg btn-default" role="button">β<span class="btn_txt">movePl</span></button>
|
||||
<button value="/all/move/0/1" class="command btn btn-block btn-lg btn-default" role="button">β<span class="btn_txt">movePl</span></button>
|
||||
<button value="/sync/all" class="command btn btn-block btn-lg btn-default" role="button">↭<span class="btn_txt">Sync</span></button>
|
||||
</p>
|
||||
</div>
|
||||
|
@ -43,6 +43,7 @@
|
|||
<div class="col_1">
|
||||
<button value="/{{host}}/poweroff" class="command btn btn-block btn-lg btn-default" role="button">⏻<span class="btn_txt">Éteindre</span></button>
|
||||
<button value="/{{host}}/reboot" class="command btn btn-block btn-lg btn-default" role="button">↺<span class="btn_txt">Redémarrer</span></button>
|
||||
<button value="/{{host}}/blink" class="command btn btn-block btn-lg btn-default" role="button">💡<span class="btn_txt">Blink</span></button>
|
||||
<p id="status_{{ host }}">{{status_message}}</p>
|
||||
<p id="signal_{{ host }}">
|
||||
<span style="">Link:</span>
|
||||
|
|
Loading…
Reference in New Issue