Exemplo n.º 1
0
    def _s_runCommand(cls,
                      logger,
                      args,
                      killTimeout=DEAFULT_KILL_TIMEOUT,
                      warningTimeout=DEAFULT_WARNING_TIMEOUT,
                      shell=False):
        __pychecker__ = "unusednames=cls"
        subprocess = a.infra.subprocess.Subprocess("bios", logger)
        if not shell and isinstance(args, str):
            args = args.split()
        try:
            logger("run-command").notice("running command, args=%s", args)
            subprocess.start(args,
                             stdout=originalsubprocess.PIPE,
                             stderr=originalsubprocess.PIPE,
                             shell=shell)
            omreportStdout, omreportStderr = subprocess.communicate(
                killTimeOut=killTimeout, warningTimeOut=warningTimeout)
            logger("run-command").notice("command stdout = %s, stderr = %s",
                                         omreportStdout, omreportStderr)
        except Exception as exception:
            logger("run-command").error("Failed executing cmd %s, error=%s",
                                        args,
                                        exception,
                                        exc_info=1)
            return (1, "", "")

        returnCode = subprocess.getReturnCode()
        logger("run-command").notice("command rc = %s", returnCode)
        return (returnCode, omreportStdout, omreportStderr)
Exemplo n.º 2
0
    def _runCommand(self,
                    cmd,
                    killTimeout=DEAFULT_KILL_TIMEOUT,
                    warningTimeout=DEAFULT_WARNING_TIMEOUT,
                    shell=False):
        subprocess = a.infra.subprocess.Subprocess("boot-utils", self._log)
        args = cmd
        if not shell:
            args = cmd.split()

        try:
            subprocess.start(args,
                             stdout=originalsubprocess.PIPE,
                             stderr=originalsubprocess.PIPE,
                             shell=shell)
            omreportStdout, omreportStderr = subprocess.communicate(
                killTimeOut=killTimeout, warningTimeOut=warningTimeout)
        except Exception as exception:
            self._log("run-command").error("Failed executing cmd %s, error=%s",
                                           args,
                                           exception,
                                           exc_info=1)
            return (1, "", "")

        returnCode = subprocess.getReturnCode()
        return (returnCode, omreportStdout, omreportStderr)
Exemplo n.º 3
0
 def _runCommand (self, cmd, killTimeout = DEAFULT_KILL_TIMEOUT, warningTimeout = DEAFULT_WARNING_TIMEOUT, shell = False):
     subprocess = a.infra.subprocess.Subprocess("boot-utils", self._log)
     args = cmd
     if not shell:
         args = cmd.split()
     
     try:
         subprocess.start(args, stdout = originalsubprocess.PIPE, stderr = originalsubprocess.PIPE, shell = shell)
         omreportStdout, omreportStderr = subprocess.communicate(killTimeOut = killTimeout, warningTimeOut = warningTimeout)
     except Exception as exception:
         self._log("run-command").error("Failed executing cmd %s, error=%s", args, exception, exc_info = 1)
         return (1, "", "")
     
     returnCode = subprocess.getReturnCode()                
     return (returnCode, omreportStdout, omreportStderr)
Exemplo n.º 4
0
 def _s_runCommand (cls, logger, args, killTimeout = DEAFULT_KILL_TIMEOUT, warningTimeout = DEAFULT_WARNING_TIMEOUT, shell = False):
     __pychecker__ = "unusednames=cls"
     subprocess = a.infra.subprocess.Subprocess("bios", logger)
     if not shell and isinstance(args, str):
         args = args.split()        
     try:
         logger("run-command").notice("running command, args=%s", args)
         subprocess.start(args, stdout = originalsubprocess.PIPE, stderr = originalsubprocess.PIPE, shell = shell)
         omreportStdout, omreportStderr = subprocess.communicate(killTimeOut = killTimeout, warningTimeOut = warningTimeout)
         logger("run-command").notice("command stdout = %s, stderr = %s", omreportStdout, omreportStderr)
     except Exception as exception:
         logger("run-command").error("Failed executing cmd %s, error=%s", args, exception, exc_info = 1)
         return (1, "", "")
     
     returnCode = subprocess.getReturnCode()                
     logger("run-command").notice("command rc = %s", returnCode)
     return (returnCode, omreportStdout, omreportStderr)
Exemplo n.º 5
0
    def _readOmreport (self, killTimeout, warningTimeout):
        # TODO(shmulika): write doc
        subprocess = a.infra.subprocess.Subprocess("omreport-reader", self._log)
        args = [OmreportReader.OMREPORT_CMD]
        args.extend(self._omreportArgs)
        args = " ".join(args)
        
        self._wasWarningTimeout = False
        self._wasKillingTimeout = False

        try:
            self._log("read-starting").debug2("starting the omreport with args=%s", args)
            subprocess.start(args, stdout = originalsubprocess.PIPE, shell = True)
        except:
            self._log("read-start-failed").error("failed reading omreport with args=%s", args, exc_info = 1)
            return None

        try:
            self._log("read-communicate").debug2("communicating (waiting for stdout result) with omreport process, with KillTimeout=%s", OmreportReader.OMREPORT_DEFAULT_KILL_TIMEOUT)
            omreportStdout, omreportStderr = subprocess.communicate(killTimeOut = killTimeout, warningTimeOut = warningTimeout)
        except:
            self._log("read-communicate-failed").error("failed communicating with omreport with args=%s", args, exc_info = 1)
            return None

        self._wasKillingTimeout = subprocess.hasTimeoutKilling() or subprocess.hasTimeoutTerminating()
        self._wasWarningTimeout = subprocess.hasTimeoutWarning()        

        returnCode = subprocess.getReturnCode()
        if returnCode != 0:
            self._log("read-omreport-failed").error("running omreport with args=%s, exited with return code = %s", args, returnCode)
            return None

        if omreportStdout is None:
            self._log("read-omreport-no-stdout").error("failed getting stdout of omreport with args=%s", args)
            return None

        self._log("read-done").debug2('omreport with args=%s, finished with stdout="""%s"""', args, omreportStdout)
        return omreportStdout