예제 #1
0
 def match(self, connection, command, regexp, grouplist=[1], timeout=10):
     """ Expect.match wrapper """
     try:
         self.logger.debug(multiprocessing.current_process().name + ": matching '%s' against '%s'" % (command, regexp.pattern))
         Expect.enter(connection, command)
         result = Expect.match(connection, regexp, grouplist, timeout)
         self.log.append({"result": "passed", "match": regexp.pattern, "command": command, "value": str(result)})
         self.logger.debug(multiprocessing.current_process().name + ": matched '%s'" % result)
         return result
     except ExpectFailed, err:
         self.log.append({"result": "failed", "match": regexp.pattern, "command": command, "actual": err.message})
         self.logger.debug(multiprocessing.current_process().name + ": match failed '%s'" % err.message)
         return None
예제 #2
0
 def get_result(self, connection, command, timeout=10):
     """ Expect.match wrapper """
     try:
         self.logger.debug(multiprocessing.current_process().name + ": getting result for '%s'" % command)
         Expect.enter(connection, "echo '###START###'; " + command + "; echo '###END###'")
         regexp = re.compile(".*\r\n###START###\r\n(.*)\r\n###END###\r\n.*", re.DOTALL)
         result = Expect.match(connection, regexp, [1], timeout)
         self.log.append({"result": "passed", "command": command, "value": result[0]})
         self.logger.debug(multiprocessing.current_process().name + ": got result: '%s'" % result[0])
         return result[0]
     except ExpectFailed, err:
         self.log.append({"result": "failed", "command": command, "actual": err.message})
         self.logger.debug(multiprocessing.current_process().name + ": getting failed: '%s'" % err.message)
         return None