def listenThread(self): if self.listener is None: self.listener = socket() try: self.listener.bind((TARGET_IP, TARGET_PORT)) self.listener.listen(0) print("Listening on {}:{}".format(TARGET_IP, TARGET_PORT)) while 1: newSocket, addr = self.listener.accept() newClient = ClientWorker(newSocket, self.queue, addr) newClient.start() self.clientList.append(newClient) print("Client connected from {}".format(addr)) finally: self.close()
def run(args): secure = secure_user_connection(args.server, debug=args.debug) password = checksum_chain([args.username, args.password]) u = ClientWorker.from_creds(secure, args.username, password, debug=args.debug) if not u.is_logged: print('Error loggin!') exit(-1) c = Crypto(password, debug=args.debug) s = Syncrypto(u, c, args.folder, debug=args.debug) return s
# Updated: Timeout will occur after 3 seconds to account for a readline (not knowing the size of the message) usb = serial.Serial(port='COM5', baudrate=57600) # Create a message queue for the serial communication usbQ = Queue() # Instantiating a rover object #simulation = rover() # Instantiation of a whole message #message = [] # Print out what port is in use print('Port: ' + usb.name) # Building a new client worker object usbClient = ClientWorker(usb, usbQ, usb.name, usb.write, usb.readline) print('Client built') # Start the client worker object thread usbClient.start() print('Client thread started') # Look to receive a message <- Blocking outmsg = InternalMessage(CLIENT, DEBUG_MSG, b'hello') def outfunc(): try: while True: usbClient.send(outmsg) except serial.SerialException: pass outthread = Thread(target=outfunc, daemon=True)
if not args.folder and not args.register: print('Pleas specify folder to sync!') exit(0) if not args.username: args.username = input('Username: '******'Password: '******'\n' + '#' * 15) pprint(user_inf) exit() if not os.path.exists(os.path.join(args.folder, '.syncrypto')) and not args.init: print('Please, initalize folder for synchronization.\n' 'Run app with key "-i"') exit() if args.init: args.folder = os.path.normpath(os.path.abspath(args.folder))