Exemplo n.º 1
0
 def onecmd(self, s):
     if not s.startswith('#'):
         command = s.split(' ')[0]
         if command == '' and not self.__input_buffer:
             pass
         elif self.context.connection == None and \
                 command.strip() not in EngineShell.OFF_LINE_CONTENT:
             self._error(Messages.Error.INVALID_COMMAND % command)
         else:
             try:
                 if s.endswith('\\') and s != 'EOF':
                     self.__set_prompt(mode=PromptMode.Multiline)
                     self.__input_buffer += ' ' + s.replace('\\', '') \
                     if not s.startswith(' ') and self.__input_buffer != ''\
                     else s.replace('\\', '')
                     return
                 elif self.__input_buffer != '' and s != 'EOF':
                     self.__input_buffer += ' ' + s \
                     if not s.startswith(' ') else s
                     s = self.__input_buffer
                     self.__input_buffer = ''
                     self.__set_prompt(mode=PromptMode.Original)
                 return cmd.Cmd.onecmd(self, s)
             finally:
                 if self.context.status == \
                    self.context.SYNTAX_ERROR \
                    or \
                    self.context.status == \
                    self.context.COMMAND_ERROR \
                    or \
                    self.context.status == \
                    self.context.UNKNOWN_ERROR:
                     self.onError.fire()
                 elif self.context.status == \
                    self.context.COMMUNICATION_ERROR:
                     self.__last_status = self.context.status
                     self.onError.fire()
                     StateMachine.communication_error(
                     )  # @UndefinedVariable
                 elif self.context.status == \
                    self.context.AUTHENTICATION_ERROR:
                     self.__last_status = self.context.status
                     self.onError.fire()
                     StateMachine.unauthorized()  # @UndefinedVariable
                 elif self.__last_status <> -1 and \
                      (
                         (
                             self.__last_status == self.context.COMMUNICATION_ERROR
                             and
                             StateMachine.get_current_state() != DFSAState.COMMUNICATION_ERROR
                         )
                       or \
                         (
                             self.__last_status == self.context.AUTHENTICATION_ERROR
                             and
                             StateMachine.get_current_state() != DFSAState.UNAUTHORIZED
                         )
                      ):
                     self.__set_prompt(mode=PromptMode.Original)
                     self.__last_status = -1
Exemplo n.º 2
0
 def onecmd(self, s):
     if not s.startswith("#"):
         command = s.split(" ")[0]
         if command == "" and not self.__input_buffer:
             pass
         elif self.context.connection == None and command.strip() not in EngineShell.OFF_LINE_CONTENT:
             self._error(Messages.Error.INVALID_COMMAND % command)
         else:
             try:
                 if s.endswith("\\") and s != "EOF":
                     self.__set_prompt(mode=PromptMode.Multiline)
                     self.__input_buffer += (
                         " " + s.replace("\\", "")
                         if not s.startswith(" ") and self.__input_buffer != ""
                         else s.replace("\\", "")
                     )
                     return
                 elif self.__input_buffer != "" and s != "EOF":
                     self.__input_buffer += " " + s if not s.startswith(" ") else s
                     s = self.__input_buffer
                     self.__input_buffer = ""
                     self.__set_prompt(mode=PromptMode.Original)
                 return cmd.Cmd.onecmd(self, s)
             finally:
                 if (
                     self.context.status == self.context.SYNTAX_ERROR
                     or self.context.status == self.context.COMMAND_ERROR
                     or self.context.status == self.context.UNKNOWN_ERROR
                 ):
                     self.onError.fire()
                 elif self.context.status == self.context.COMMUNICATION_ERROR:
                     self.__last_status = self.context.status
                     self.onError.fire()
                     StateMachine.communication_error()  # @UndefinedVariable
                 elif self.context.status == self.context.AUTHENTICATION_ERROR:
                     self.__last_status = self.context.status
                     self.onError.fire()
                     StateMachine.unauthorized()  # @UndefinedVariable
                 elif self.__last_status <> -1 and (
                     (
                         self.__last_status == self.context.COMMUNICATION_ERROR
                         and StateMachine.get_current_state() != DFSAState.COMMUNICATION_ERROR
                     )
                     or (
                         self.__last_status == self.context.AUTHENTICATION_ERROR
                         and StateMachine.get_current_state() != DFSAState.UNAUTHORIZED
                     )
                 ):
                     self.__set_prompt(mode=PromptMode.Original)
                     self.__last_status = -1