Files
help/wiki-to-help/executor.py
Norbert Thiebaud 61173c1b58 move help structure one directory up
Change-Id: Ie970e39fbb6795a92d9fdd13510409d7dcd071bc
2012-10-16 11:07:30 -05:00

22 lines
664 B
Python

import subprocess, os
class Executor(object):
def __init__(self,showErr=True,showOutput=True,showCmd=False):
self.showCmd=showCmd
if showErr: self.stderr = None
else: self.stderr=open(os.devnull,"w")
if showOutput: self.stdout = None
else: self.stdout=open(os.devnull,"w")
def __call__(self,*cmd):
"""
Execute a program, e.g. Executor()("/bin/ls","/home")
@cmd Command, args
@return boolean True if succeed
"""
if self.showCmd:
print cmd
return (subprocess.Popen(list(cmd),stderr=self.stderr,
stdout=self.stdout).wait() == 0)