コード例 #1
0
    def handleCommand(self, oResponse, oConnection):
        """
        Handles a command from the test manager.

        Some commands will close the connection, others (generally the simple
        ones) wont, leaving the caller the option to use it for log flushing.

        Returns success indicator.
        Raises no exception.
        """
        try:
            sCmdName = oResponse.getStringChecked(
                constants.tbresp.ALL_PARAM_RESULT)
        except Exception as oXcpt:
            oConnection.close()
            return False

        # Do we know the command?
        fRc = False
        if sCmdName in self._dfnCommands:
            testboxcommons.log(sCmdName)
            try:
                # Execute the handler.
                fRc = self._dfnCommands[sCmdName](oResponse, oConnection)
            except Exception as oXcpt:
                # NACK the command if an exception is raised during parameter validation.
                testboxcommons.log1Xcpt('Exception executing "%s": %s' %
                                        (sCmdName, oXcpt))
                if oConnection.isConnected():
                    try:
                        oConnection.sendReplyAndClose(
                            constants.tbreq.COMMAND_NACK, sCmdName)
                    except Exception as oXcpt2:
                        testboxcommons.log('Failed to NACK "%s": %s' %
                                           (sCmdName, oXcpt2))
        elif sCmdName in [
                constants.tbresp.STATUS_DEAD, constants.tbresp.STATUS_NACK
        ]:
            testboxcommons.log('Received status instead of command: %s' %
                               (sCmdName, ))
        else:
            # NOTSUP the unknown command.
            testboxcommons.log('Received unknown command: %s' % (sCmdName, ))
            try:
                oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NOTSUP,
                                              sCmdName)
            except Exception as oXcpt:
                testboxcommons.log('Failed to NOTSUP "%s": %s' %
                                   (sCmdName, oXcpt))
        return fRc
コード例 #2
0
    def handleCommand(self, oResponse, oConnection):
        """
        Handles a command from the test manager.

        Some commands will close the connection, others (generally the simple
        ones) wont, leaving the caller the option to use it for log flushing.

        Returns success indicator.
        Raises no exception.
        """
        try:
            sCmdName = oResponse.getStringChecked(constants.tbresp.ALL_PARAM_RESULT);
        except Exception as oXcpt:
            oConnection.close();
            return False;

        # Do we know the command?
        fRc = False;
        if sCmdName in self._dfnCommands:
            testboxcommons.log(sCmdName);
            try:
                # Execute the handler.
                fRc = self._dfnCommands[sCmdName](oResponse, oConnection)
            except Exception as oXcpt:
                # NACK the command if an exception is raised during parameter validation.
                testboxcommons.log1Xcpt('Exception executing "%s": %s' % (sCmdName, oXcpt));
                if oConnection.isConnected():
                    try:
                        oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NACK, sCmdName);
                    except Exception as oXcpt2:
                        testboxcommons.log('Failed to NACK "%s": %s' % (sCmdName, oXcpt2));
        elif sCmdName in [constants.tbresp.STATUS_DEAD, constants.tbresp.STATUS_NACK]:
            testboxcommons.log('Received status instead of command: %s' % (sCmdName, ));
        else:
            # NOTSUP the unknown command.
            testboxcommons.log('Received unknown command: %s' % (sCmdName, ));
            try:
                oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NOTSUP, sCmdName);
            except Exception as oXcpt:
                testboxcommons.log('Failed to NOTSUP "%s": %s' % (sCmdName, oXcpt));
        return fRc;
コード例 #3
0
            sCmdName = oResponse.getStringChecked(
                constants.tbresp.ALL_PARAM_RESULT)
        except Exception, oXcpt:
            oConnection.close()
            return False

        # Do we know the command?
        fRc = False
        if sCmdName in self._dfnCommands:
            testboxcommons.log(sCmdName)
            try:
                # Execute the handler.
                fRc = self._dfnCommands[sCmdName](oResponse, oConnection)
            except Exception, oXcpt:
                # NACK the command if an exception is raised during parameter validation.
                testboxcommons.log1Xcpt('Exception executing "%s": %s' %
                                        (sCmdName, oXcpt))
                if oConnection.isConnected():
                    try:
                        oConnection.sendReplyAndClose(
                            constants.tbreq.COMMAND_NACK, sCmdName)
                    except Exception, oXcpt2:
                        testboxcommons.log('Failed to NACK "%s": %s' %
                                           (sCmdName, oXcpt2))
        elif sCmdName in [
                constants.tbresp.STATUS_DEAD, constants.tbresp.STATUS_NACK
        ]:
            testboxcommons.log('Received status in stead of command: %s' %
                               (sCmdName, ))
        else:
            # NOTSUP the unknown command.
            testboxcommons.log('Received unknown command: %s' % (sCmdName, ))
コード例 #4
0
        try:
            sCmdName = oResponse.getStringChecked(constants.tbresp.ALL_PARAM_RESULT);
        except Exception, oXcpt:
            oConnection.close();
            return False;

        # Do we know the command?
        fRc = False;
        if sCmdName in self._dfnCommands:
            testboxcommons.log(sCmdName);
            try:
                # Execute the handler.
                fRc = self._dfnCommands[sCmdName](oResponse, oConnection)
            except Exception, oXcpt:
                # NACK the command if an exception is raised during parameter validation.
                testboxcommons.log1Xcpt('Exception executing "%s": %s' % (sCmdName, oXcpt));
                if oConnection.isConnected():
                    try:
                        oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NACK, sCmdName);
                    except Exception, oXcpt2:
                        testboxcommons.log('Failed to NACK "%s": %s' % (sCmdName, oXcpt2));
        elif sCmdName in [constants.tbresp.STATUS_DEAD, constants.tbresp.STATUS_NACK]:
            testboxcommons.log('Received status in stead of command: %s' % (sCmdName, ));
        else:
            # NOTSUP the unknown command.
            testboxcommons.log('Received unknown command: %s' % (sCmdName, ));
            try:
                oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NOTSUP, sCmdName);
            except Exception, oXcpt:
                testboxcommons.log('Failed to NOTSUP "%s": %s' % (sCmdName, oXcpt));
        return fRc;