Implement HTTP compression

This commit is contained in:
Lucca Pirovano
2026-07-20 17:57:24 -04:00
parent 5977e6fc7d
commit 4a4625028b
9 changed files with 359 additions and 138 deletions
+6 -3
View File
@@ -9,15 +9,17 @@ import time
import threading
class NaoMusicPlayer:
def __init__(self, session, nao_ip):
def __init__(self, session, nao_ip, ssh_port=22):
self.session = session
self.player = session.service("ALAudioPlayer")
self.nao_ip = nao_ip
self.ssh_port = ssh_port
self.music_dir = "/home/nao/music"
self.local_path = "/tmp/song.mp3"
self.remote_path = f"{self.music_dir}/song.mp3"
try:
subprocess.run(["sshpass", "-p", "nao", "ssh", f"nao@{nao_ip}", f"mkdir -p {self.music_dir}"],
subprocess.run(["sshpass", "-p", "nao", "ssh", "-p", str(self.ssh_port),
f"nao@{nao_ip}", f"mkdir -p {self.music_dir}"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except: pass
self.current_file = None
@@ -110,7 +112,8 @@ class NaoMusicPlayer:
t = threading.Thread(target=ticker, daemon=True)
t.start()
scp_result = subprocess.run(
["sshpass", "-p", "nao", "scp", self.local_path, f"nao@{self.nao_ip}:{self.remote_path}"],
["sshpass", "-p", "nao", "scp", "-P", str(self.ssh_port),
self.local_path, f"nao@{self.nao_ip}:{self.remote_path}"],
capture_output=True, text=True, timeout=60
)
stop_ticker.set()