コード例 #1
0
ファイル: cmd.py プロジェクト: TE-ToshiakiTanaka/bantorra.old
    def __exec(self, cmd, timeout=TIMEOUT):
        proc = Process(cmd, self.queue)
        proc.start()
        proc.join(timeout)

        if proc.is_alive():
            proc.kill()
            time.sleep(3)
            L.debug("proc.terminate. %s" % proc.is_alive())

        if self.queue.empty():
            return None
        return self.queue.get()
コード例 #2
0
 def get_config(cls, conf=""):
     cls.service_conf = {}
     if conf == "":
         conf = os.path.join(define.APP_BIN, "port.ini")
         L.debug(conf)
     try:
         config = ConfigParser.ConfigParser()
         config.read(conf)
         for section in config.sections():
             for option in config.options(section):
                 cls.service_conf["%s" % option] = config.get(section, option)
     except Exception as e:
         L.warning("error: could not read config file: %s" % e)
コード例 #3
0
ファイル: cmd.py プロジェクト: TE-ToshiakiTanaka/bantorra.old
 def run(self):
     L.info("Command Send : %s" % self.command)
     args = self.command.split(" ")
     subproc_args = { 'stdin'        : subprocess.PIPE,
                      'stdout'       : subprocess.PIPE,
                      'stderr'       : subprocess.PIPE,
     }
     try:
         proc = subprocess.Popen(args, **subproc_args)
     except OSError:
         L.info("Failed to execute command: %s" % args[0])
         sys.exit(1)
     (stdout, stderr) = proc.communicate()
     code = proc.wait()
     L.debug("Command Resturn Code: %d" % code)
     self.queue.put(stdout)
コード例 #4
0
 def load(self, testcase):
     """
         TestCase Load Method.
         .. warning::
             Default Settings, TestCase Folder is only bantorra/script.
             TestCase Class is only inheritant of testcase_base.py
         :arg string testcase: testcase name. only ".py" file.
         :return module: module object.
     """
     sys.path.append(define.APP_SCRIPT)
     if testcase.find(".py") != -1:
         script = testcase
     else:
         script = testcase + ".py"
     path = os.path.join(define.APP_SCRIPT, script)
     name = script[:script.find(".")]
     L.debug("TestCase : %s" % path)
     if os.path.exists(path):
         f, n, d = imp.find_module(str(name))
         return imp.load_module(name, f, n, d)
     else:
         return False
コード例 #5
0
ファイル: cmd.py プロジェクト: TE-ToshiakiTanaka/bantorra.old
 def kill(self):
     L.debug("Kill This Process.")
     self.terminate()