Beispiel #1
0
def sendFileToClient(filename, hostname):
    tries = 0
    while tries < 4 :
        cmd = "sshpass -p raspberry scp -oStrictHostKeyChecking=no %s/%s pi@%s.local:/home/pi/client/wav/" % (audioFilesDir, filename, hostname)
        os.system('ssh-keygen -f "/home/pi/.ssh/known_hosts" -R "'+hostname+'.local"')
        if os.system(cmd) == 0 : 
            print("successfully dispatched %s to %s"%(filename, hostname))
            #FIXME for some reason this part of the function is never executed (os.system blocking ?)
            print("asking %s for fileList" % hostname )
            clients.sendOSC(hostname, "/getFileList") # to update the fileList on the UI
            socketio.emit("successfullDispatch",{"filename":filename, "hostname":hostname}, namespace = "/home")
            return True
        else : tries+=1
    print("dispatching of %s to %s via sFTP failed 3 times in a row"%(filename, hostname))
    socketio.emit("dispatchFailed",{"filename":filename, "hostname":hostname}, namespace = "/home")
    return False
Beispiel #2
0
def deleteFile(data):
    clients.sendOSC(data["hostname"], "/delete", [urllib.parse.unquote(data["fileSelected"])])
Beispiel #3
0
def playFile(data):
    clients.sendOSC(data["hostname"], "/play", [urllib.parse.unquote(data["fileSelected"])])
Beispiel #4
0
def stopFile(hostname):
    hostname = urllib.parse.unquote(hostname)
    clients.sendOSC(hostname, "/stop")  
Beispiel #5
0
def setVolume(data):
    volName = ["microphone", "analogIN", "transducer", "analogOUT"][data["index"]]
    clients.sendOSC(data["hostname"], "/volume", [volName, data["volume"]])
    print("changed volumes for {}:{} to {}".format(data["hostname"], volName, data["volume"]))