(self)
| 30 | self.run() |
| 31 | |
| 32 | def run(self): |
| 33 | class Alarm(Exception): |
| 34 | pass |
| 35 | def alarm_handler(signum, frame): |
| 36 | raise Alarm |
| 37 | |
| 38 | try: |
| 39 | self.process = Popen(self.args, shell=True, stdout=PIPE, stderr=PIPE) |
| 40 | if self.timeout != -1: |
| 41 | signal(SIGALRM, alarm_handler) |
| 42 | alarm(self.timeout) |
| 43 | |
| 44 | try: |
| 45 | self.stdout, self.stderr = self.process.communicate() |
| 46 | if self.timeout != -1: |
| 47 | alarm(0) |
| 48 | except Alarm: |
| 49 | os.kill(self.process.pid, SIGKILL) |
| 50 | raise CloudRuntimeException("Timeout during command execution") |
| 51 | |
| 52 | self.success = self.process.returncode == 0 |
| 53 | except: |
| 54 | raise CloudRuntimeException(formatExceptionInfo()) |
| 55 | |
| 56 | if not self.success: |
| 57 | logging.debug("Failed to execute:" + self.getErrMsg()) |
| 58 | |
| 59 | def isSuccess(self): |
| 60 | return self.success |
no test coverage detected