from datetime import datetime
from subprocess import PIPE, Popen
log = logging.getLogger(__name__)
PUBLIC_DIR_RE = re.compile(r'.*?/usr/lib/python(\d(?:.\d+)?)/(site|dist)-packages')
def __init__(self, func):
def __call__(self, *args, **kwargs):
key = dumps((args, kwargs))
if key not in self.cache:
self.cache[key] = self.func(*args, **kwargs)
def execute(command, cwd=None, env=None, log_output=None):
"""Execute external shell commad.
:param cdw: currennt working directory
* opened log file or path to this file, or
* None if output should be included in the returned dict, or
* False if output should be redirectored to stdout/stderr
args = {'shell': True, 'cwd': cwd, 'env': env}
args.update(stdout=PIPE, stderr=PIPE)
if isinstance(log_output, str):