def execute(self, context, args, command, log_file=None): if log_file is False and self.cfg.really_quiet: log_file = None command = command.format(**args) if 'PYTHONPATH' in args: env = dict(context['ENV']) env['PYTHONPATH'] = args['PYTHONPATH'] else: env = context['ENV'] log.info(command) return execute(command, context['dir'], env, log_file)
def _execute(self, command, version=None, cache=True): version = Version(version or self.version) command = "{} -c '{}'".format(self._vstr(version), command.replace("'", "\'")) if cache and command in self.__class__._cache: return self.__class__._cache[command] output = execute(command) if output['returncode'] != 0: log.debug(output['stderr']) raise Exception('{} failed with status code {}'.format(command, output['returncode'])) result = output['stdout'].splitlines() if len(result) == 1: result = result[0] if cache: self.__class__._cache[command] = result return result