def _start_process(self, env=None): path = self.PROCESS_PATH flags = getattr(self, "FLAGS", []) kws = {} if not options.is_verbose(): FNULL = open('/dev/null', 'w') kws.update({'stdout': FNULL, 'stderr': subprocess.PIPE}) if env: kws['env'] = env command = [path] + flags log("Starting %s" % ' '.join(command)) try: return subprocess.Popen([path] + flags, **kws) except OSError as e: raise RuntimeError("Error starting %s: %s" % (path, e))
def _process_watch_cb(self): if self.process_watch_timeout == 0 or self.process is None: # The GLib seems to call the timeout after we've removed it # sometimes, which causes errors unless we detect it. return False status = self.process.poll() if status is None: return True # continue elif status == 0 and not self.abort_if_process_exits_with_status_0: return True # continue else: self.process_watch_timeout = 0 if options.is_verbose(): error = "" else: error = self.process.stderr.read() raise RuntimeError("%s exited with status: %i\n%s" % (self.PROCESS_NAME, status, error))
def _start_process(self): global _process_list _process_list.append(self) path = self.PROCESS_PATH flags = getattr(self, "FLAGS", []) kws = {} if not options.is_verbose(): FNULL = open('/dev/null', 'w') kws = {'stdout': FNULL, 'stderr': subprocess.PIPE} command = [path] + flags log("Starting %s" % ' '.join(command)) try: return subprocess.Popen([path] + flags, **kws) except OSError as e: raise RuntimeError("Error starting %s: %s" % (path, e))
def log(message): if options.is_verbose(): print(message)