Exemplo n.º 1
0
def test_commandSerialization():
    c = command.factory(["BEGIN", True, ['whatever', 'end']])
    s = c.serialize()

    cmd = command.unserialize(s)
    logging.debug("unserisalized: %s" % type(cmd.result))

    assert (cmd.success)
    assert (type(cmd.result) == list)
    assert (cmd.args == None)
    assert (cmd.result == ['whatever', 'end'])
    assert (str(cmd).startswith("BEGIN"))
Exemplo n.º 2
0
def test_commandSerialization():
    c = command.factory( ["BEGIN", True, ['whatever','end']])
    s = c.serialize()

    cmd=command.unserialize(s)
    logging.debug("unserisalized: %s" % type(cmd.result))

    assert(cmd.success)
    assert(type(cmd.result) == list)
    assert(cmd.args == None)
    assert(cmd.result == ['whatever','end'])
    assert(str(cmd).startswith("BEGIN"))
Exemplo n.º 3
0
    def receive_command(self):
        assert (isinstance(self.vm, str))
        #logging.debug("PROTO receiveCommand %s" % (self.client))
        msg = self.mq.receive_client(self.vm, blocking=True, timeout=self.timeout)
        if config.verbose:
            logging.debug("PROTO C receive_command %s, %s" % (self.vm, msg))
        cmd = command.unserialize(msg)
        cmd.vm = self.vm

        if cmd.side == "meta":
            return self._meta(cmd)
        else:
            return self._execute_command(cmd)
Exemplo n.º 4
0
    def receive_command(self):
        assert (isinstance(self.vm, str))
        #logging.debug("PROTO receiveCommand %s" % (self.client))
        msg = self.mq.receive_client(self.vm,
                                     blocking=True,
                                     timeout=self.timeout)
        if config.verbose:
            logging.debug("PROTO C receive_command %s, %s" % (self.vm, msg))
        cmd = command.unserialize(msg)
        cmd.vm = self.vm

        if cmd.side == "meta":
            return self._meta(cmd)
        else:
            return self._execute_command(cmd)
Exemplo n.º 5
0
def test_commandSerialize():
    c = command.factory(("BEGIN", False, "nothing"))
    s = c.serialize()
    cmd = command.unserialize(s)
    assert (not cmd.success)

    logging.debug("cmd: %s %s", cmd, type(cmd))
    assert (str(cmd).startswith("BEGIN"))

    #assert str(type(cmd)) == "<class 'AVCommon.Command_START.Command_START'>", "type: %s" % str(type(cmd))
    #assert str(type(cmd)) == "<class 'Command_START.Command_START'>", "type: %s" % str(type(cmd))

    command.factory(("BEGIN", None, None))
    try:
        command.factory(("BEGIN", "", None))
        assert (False)
    except:
        pass
Exemplo n.º 6
0
def test_commandSerialize():
    c = command.factory( ("BEGIN", False, "nothing") )
    s = c.serialize()
    cmd = command.unserialize(s)
    assert(not cmd.success)

    logging.debug("cmd: %s %s", cmd, type(cmd))
    assert(str(cmd).startswith("BEGIN"))

    #assert str(type(cmd)) == "<class 'AVCommon.Command_START.Command_START'>", "type: %s" % str(type(cmd))
    #assert str(type(cmd)) == "<class 'Command_START.Command_START'>", "type: %s" % str(type(cmd))

    command.factory( ("BEGIN", None, None) )
    try:
        command.factory( ("BEGIN", "", None) )
        assert(False)
    except:
        pass