def __enter__(self): self.outxml = NamedTemporaryFile(prefix='elbe', suffix='xml') cmd = '%s preprocess %s -o %s %s' % (elbe_exe, self.options, self.outxml.name, self.xmlfile) ret, _, err = command_out_stderr(cmd) if ret != 0: print("elbe preprocess failed.", file=sys.stderr) print(err, file=sys.stderr) raise CommandError(cmd, ret) return self
def do(self, cmd, allow_fail=False, input=None): if input == None: self.printo("running cmd +%s+" % cmd) else: self.printo("running cmd +%s with STDIN %s+" % (cmd, input)) self.verbatim_start() ret, out = command_out(cmd, input=input, output=self.fp) self.verbatim_end() if ret != 0: self.printo("Command failed with errorcode %d" % ret) if not allow_fail: raise CommandError(cmd, ret)
def do(self, cmd, allow_fail=False, stdin=None, env_add=None): if stdin is None: self.printo("running cmd +%s+" % cmd) else: self.printo("running cmd +%s with STDIN %s+" % (cmd, stdin)) self.verbatim_start() ret, _ = command_out(cmd, stdin=stdin, output=self.fp, env_add=env_add) self.verbatim_end() if ret != 0: self.printo("Command failed with errorcode %d" % ret) if not allow_fail: raise CommandError(cmd, ret)
def get_command_out(self, cmd, allow_fail=False): self.printo("getting output from cmd +%s+" % cmd) ret, output, stderr = command_out_stderr(cmd) if len(stderr) != 0: self.verbatim_start() self.print_raw(stderr) self.verbatim_end() if ret != 0: self.printo("Command failed with errorcode %d" % ret) if not allow_fail: raise CommandError(cmd, ret) return output