Example #1
0
    def _dispatch_command(self, client, line):
        """
		Try to parse the line and dispatch the command to the relevant
		destination (server or client).
		"""

        # Try to parse the line
        try:
            counter, cmd, args = command.parse(line)
        except Exception, e:
            return '0 NOT_OK ' + str(e)
Example #2
0
    def _dispatch_command(self, client, line):
        """
		Try to parse the line and dispatch the command to the relevant
		destination (server or client).
		"""

        # Try to parse the line
        try:
            counter, cmd, args = command.parse(line)
        except Exception, e:
            return "0 NOT_OK " + str(e)
Example #3
0
    def push_command(self, line):
        # Run from network thread

        try:
            self._command_lock.acquire()

            tokens = parse_tokens(line)
            id = tokens[0]
            if id == 'UNICAST' or id == 'BROADCAST':
                id, command, args = parse(line)
                self._command_queue.append((command, args))
            elif id in self._command_store:
                status = tokens[1]
                args = tuple(tokens[2:])
                data = line[len(id) + len(status) + 2:]

                self._command_store[id].reply(status, args, data)
            else:
                raise RuntimeError, 'Got a reply for ID ' + id + ' but no matching request'
        except:
            traceback.print_exc()
        finally:
            self._command_lock.release()
Example #4
0
	def push_command(self, line):
		# Run from network thread
		
		try:
			self._command_lock.acquire()
			
			tokens = parse_tokens(line)
			id = tokens[0]
			if id == 'UNICAST' or id == 'BROADCAST':
				id, command, args = parse(line)
				self._command_queue.append((command, args))
			elif id in self._command_store:
				status = tokens[1]
				args = tuple(tokens[2:])
				data = line[len(id)+len(status)+2:]

				self._command_store[id].reply(status, args, data)
			else:
				raise RuntimeError, 'Got a reply for ID ' + id + ' but no matching request'
		except:
			traceback.print_exc()
		finally:
			self._command_lock.release()