class Process(object): def __init__(self, pid=None, command=None): self.pid = pid if self.pid is None: self.process = Popen(command) self.start_time = time() else: self.process = psutil.Process(self.pid) self.start_time = self.process.create_time() command = self.process.cmdline() self.command = ' '.join(command) def is_running(self): if self.pid is None: return self.process.poll() is None else: return self.process.is_running()