class InaturalistSearch: def __init__(self, osc_server_port=9880, osc_client_host='127.0.0.1', osc_client_port=9881): self.osc_client = Client(osc_client_host, osc_client_port) self.osc_server = Server('0.0.0.0', osc_server_port, self.osc_server_message) self.mode = 'random' self.size = 'medium_url' # "square_url" "small_url" "medium_url" "large_url" "original_url" print("Inaturalist Search Ready") def osc_server_message(self, message): #print(message) osc = message.split(" ", 1) key = message.split(" ", 1)[0] if (len(osc) > 1): rest = message.split(" ", 1)[1] else: rest = '' if key == '/exit': self.osc_server.stop() sys.exit(0) elif key == '/mode': self.mode = rest #print ("-mode "+self.mode) elif key == '/size': self.size = rest #print ("-size "+self.size) elif key == '/search': self.search(rest) else: self.search(message) def search(self, message): message = message.strip('\'') message = message.replace(",", " ") message = message.replace('à', "a") message = message.replace("â", "a") message = message.replace("é", "e") message = message.replace("è", "e") message = message.replace("ê", "e") message = message.replace("ë", "e") message = message.replace("î", "i") message = message.replace("ï", "i") message = message.replace("ô", "o") message = message.replace("ö", "o") message = message.replace("ù", "u") message = message.replace("ü", "u") message = message.replace("ç", "c") message = message.replace(")", " ") message = message.replace(", ", " ") message = message.replace("… ", " ") message = message.replace('\xe2\x80\x99', "'") InatThread(message, self.osc_client, self.mode, self.size).start()
def __init__(self, osc_server_port=9860, osc_client_host='127.0.0.1', osc_client_port=9861): self.osc_client = Client(osc_client_host, osc_client_port) self.osc_server = Server('0.0.0.0', osc_server_port, self.osc_server_message) self.mode = 'random' print("PixabaySearch Ready")
class PixabaSearch: def __init__(self, osc_server_port=9860, osc_client_host='127.0.0.1', osc_client_port=9861): self.osc_client = Client(osc_client_host, osc_client_port) self.osc_server = Server('0.0.0.0', osc_server_port, self.osc_server_message) self.mode = 'random' print("PixabaySearch Ready") def osc_server_message(self, message): #print(message) osc = message.split(" ", 1) key = message.split(" ", 1)[0] if (len(osc) > 1): rest = message.split(" ", 1)[1] else: rest = '' if key == '/exit': self.osc_server.stop() sys.exit(0) elif key == '/mode': self.mode = rest #print ("-mode " + self.mode) elif key == '/search': self.search(rest) else: self.search(message) def search(self, message): message = message.strip('\'') message = message.replace(",", " ") message = message.replace('à', "a") message = message.replace("â", "a") message = message.replace("é", "e") message = message.replace("è", "e") message = message.replace("ê", "e") message = message.replace("ë", "e") message = message.replace("î", "i") message = message.replace("ï", "i") message = message.replace("ô", "o") message = message.replace("ö", "o") message = message.replace("ù", "u") message = message.replace("ü", "u") message = message.replace("ç", "c") message = message.replace(")", " ") message = message.replace(", ", " ") message = message.replace("… ", " ") message = message.replace('\xe2\x80\x99', "'") PixaThread(message, self.osc_client, self.mode).start()
def __init__(self, osc_server_port=9880, osc_client_host='127.0.0.1', osc_client_port=9881): self.osc_client = Client(osc_client_host, osc_client_port) self.osc_server = Server('0.0.0.0', osc_server_port, self.osc_server_message) self.mode = 'random' self.size = 'medium_url' # "square_url" "small_url" "medium_url" "large_url" "original_url" print("Inaturalist Search Ready")
def __init__(self, osc_server_port=7860, osc_client_host='127.0.0.1', osc_client_port=7861): self.dest = 'en' self.osc_server = Server('127.0.0.1', osc_server_port, self.callback) self.osc_client = Client(osc_client_host, osc_client_port) print("GoogleTrans Ready")
class ErgoController: def __init__(self, osc_server_port=5550, osc_client_host='127.0.0.1', osc_client_port=5551): self.osc_server = Server('127.0.0.1', osc_server_port, self.callback) print("ErgoController Ready") asyncio.new_event_loop().run_until_complete(ImageReceiver(osc_client_host, osc_client_port)) def callback(self, address, *args): #print("callback : "+str(address)) argsStr = "" l = len(args) for x in range(0,l): argsStr += str(args[x]) if(x < (l-1)): argsStr += " " if(address == '/exit'): print("--- EXIT ---") self.osc_server.stop() sys.exit() elif(address == '/deleteData'): print('DELETE_DATA') asyncio.new_event_loop().run_until_complete(send_delete_data()) elif(address == '/socket'): WS_PATH = argsStr print('WS_PATH', WS_PATH) elif(address == '/local'): LOCAL_PATH = argsStr print('LOCAL_PATH', LOCAL_PATH) elif(address == '/server'): SERVER_PATH = argsStr print('SERVER_PATH', SERVER_PATH) elif(address == '/protocol'): print('PROTOCOL', args[0]) asyncio.new_event_loop().run_until_complete(send_protocol(args[0])) elif(address == '/pause'): print('PAUSE', argsStr) asyncio.new_event_loop().run_until_complete(send_pause(argsStr)) else: print("callback : "+str(address)) for x in range(0,len(args)): print(" " + str(args[x]))
def __init__(self, osc_server_port=6660, osc_client_host='127.0.0.1', osc_client_port=6661): self.dest = 'fr' self.osc_client = Client(osc_client_host, osc_client_port) self.osc_server = Server(host='0.0.0.0', port=osc_server_port, callback=self.callback) print("Mindat Search Ready")
def __init__(self, osc_server_port=5550, osc_client_host='127.0.0.1', osc_client_port=5551): self.osc_server = Server('127.0.0.1', osc_server_port, self.callback) print("ErgoController Ready") asyncio.new_event_loop().run_until_complete(ImageReceiver(osc_client_host, osc_client_port))