def run(self): tmp = '' while True: if self.stopped: self.socket.close() return try: tmp += self.socket.recv(self.size).decode() except socket.timeout: continue except OSError: self.close() if tmp != '' and tmp != '\n': data = tmp.split('\n') for i in range(len(data)): try: msg = jsonToDict(data[i]) self.channels[msg['type']] = msg['data'] if(msg['type'] == ACK): self.canWrite = True tmp = '' except JSONDecodeError: tmp = ''.join(data[i:]) break
def run(self): tmp = "" while True: if self.stopped: self.socket.close() return try: tmp += self.socket.recv(self.size).decode() except socket.timeout: continue except OSError: self.close() if tmp != "" and tmp != "\n": data = tmp.split("\n") for i in range(len(data)): try: msg = jsonToDict(data[i]) self.channels[msg["type"]] = msg["data"] if msg["type"] == ACK: self.canWrite = True tmp = "" except JSONDecodeError: tmp = "".join(data[i:]) break
def __run(self): tmp = '' while True: if self.stopped: self.socket.close() return try: tmp += self.socket.recv(self.size).decode() except socket.timeout: continue except OSError: self.close() if tmp != '': data = tmp.split('\n') for i in range(len(data)): try: msg = jsonToDict(data[i]) except JSONDecodeError: continue self.__cascade(msg[TYPE], msg[DATA]) if msg[TYPE] == IMAGE: self.channels[IMAGE] = decodeImg(msg[DATA]) else: self.channels[msg[TYPE]] = msg[DATA] data[i] = '' tmp = ''.join(data)
def run(self): tmp = '' while True: if self.stopped: self.socket.close() return try: tmp += self.socket.recv(self.size).decode() except socket.timeout: continue except OSError: self.close() if tmp not in ('', '\\n'): data = tmp.split('\n') # pylint: disable=consider-using-enumerate for i in range(len(data)): try: msg = jsonToDict(data[i]) self.channels[msg['type']] = msg['data'] if msg['type'] == ACK: self.canWrite = True tmp = '' except JSONDecodeError: tmp = ''.join(data[i:]) break
def __run(self): tmp = "" while True: if self.stopped: self.serial.close() return tmp += self.serial.read(self.size).decode() if tmp == READY: self.opened = True tmp = "" if tmp != "": data = tmp.split("\n") for i in range(len(data)): try: msg = jsonToDict(data[i]) except JSONDecodeError: continue self.__cascade(msg[TYPE], msg[DATA]) self.channels[msg[TYPE]] = msg[DATA] data[i] = "" tmp = "".join(data)
def run(self, size=256): if self.socketOpen: tmp = '' while self.go: tmp += self.client.recv(size).decode().encode('utf-8') try: msg = jsonToDict(tmp) if msg['type'] not in self.channels.keys(): self.registerChannel(msg['type']) self.channels[msg['type']] = msg['data'] tmp = '' except: continue return
def run(self, size=256): tmp = '' while True: tmp += self.client.recv(size).decode() try: msg = jsonToDict(tmp) if STOP in msg.keys(): self.client.close() return self.channels[msg['type']] = msg['data'] if(msg['type'] == ACK): self.canWrite = True tmp = '' except: continue