def sendToFlash(message): try: flashConnection.send(message.encode('utf-8')) except socket.error: Error.flashClientFail(flashSock, iTunesSock)
flashSock.bind(('127.0.0.1', PORT)) flashSock.listen(1) # 60 second connection to flash timeout so aethyrHelper doesn't live forever flashSock.settimeout(60) # launch flash frontend if hasattr(sys, 'frozen'): os.startfile(os.path.abspath("AethyrBin.exe")) # wait for flash to connect try: flashConnection, address = flashSock.accept() except socket.error, e: print('Exception while connecting to Flash: ' + str(e)) Error.flashClientFail(flashSock, iTunesSock) # remove timeout flashSock.setblocking(1) flashConnection.setblocking(1) # must be non-blocking to utilize threads properly iTunesSock.setblocking(0) if (Helper.isNeedUpdate()): sendToFlash('needToUpdateClient' + DELIMITER) ########## global tracks global currentLibrary