def _get_create_work_args(): try: _check_output([osp.join(projdir,'bin','create_work')],stderr=STDOUT) except CalledProcessError as e: doc = e.output matches = [g.groups() for g in [re.search('--(.*?) (.*?) ',l) for l in doc.splitlines()] if g] args = {k:{'n':int,'x':float}.get(v,str) for k,v in matches} args['additional_xml']=str return args
def __trigger_signal(self): try: output = _check_output( ['kill', '-10', str(self.__other_process_pid)]).decode() except Exception as e: self.__is_connected = False self.__debug_msg( 'Disconnected from {}. Error: {}'.format( self.__other_process_name, str(e)), 'error')
def check_output(args, stderr=STDOUT): cmd = _pre_call(args) try: return _check_output(args, stderr=stderr) except CalledProcessError, e: get_logger().debug( "Command %s returned exit code %s. This is the programs output:\n%s<<EOF>>" % (cmd, e.returncode, e.output) ) raise
def check_output(cmd, *args, **kwargs): """ Wraps subprocess.check_output and logs errors to BOINC """ try: return _check_output(cmd, stderr=STDOUT, *args, **kwargs) except CalledProcessError as e: log.printf(CRITICAL, "Error calling %s:\n%s\n", str(cmd), e.output) raise CheckOutputError except Exception as e: log.printf(CRITICAL, "Error calling %s:\n%s\n", str(cmd), str(e)) raise CheckOutputError
def get_pid(self, process_name): all_process = _check_output(['ps', 'aux']).decode().split('\n') pid = [] for process in all_process: if process_name in process: pid.append(process.split()[1]) if len(pid) == 0: return -1 elif len(pid) > 1: return -2 else: return int(pid[0])
def check_output(cmd,*args,**kwargs): """ Wraps subprocess.check_output and logs errors to BOINC """ try: return _check_output(cmd,stderr=STDOUT,*args,**kwargs) except CalledProcessError as e: log.printf(CRITICAL,"Error calling %s:\n%s\n",str(cmd),e.output) raise CheckOutputError except Exception as e: log.printf(CRITICAL,"Error calling %s:\n%s\n",str(cmd),str(e)) raise CheckOutputError
def check_output(cmd: List[str], *args: Any, **kwargs: Any) -> Any: if not cmd or not cmd[0]: raise RuntimeError( "Could not run the following command {}. Please check your PATH". format(cmd)) kwargs["stderr"] = kwargs.pop("stderr", STDOUT) shlexed = " ".join([shlex.quote(x) for x in cmd]) logging.trace("Running '%s'", shlexed) _QCMD_LOGGER.info(shlexed) try: return _check_output(cmd, *args, **kwargs).decode() except Exception as e: logging.error("'%s' failed: %s", shlexed, str(e)) _QCMD_LOGGER.error(">> %s", str(e)) raise
def check_output(args, stdin=None, stderr=STDOUT, shell=False, cwd=None, env=None, *popenargs, **popenkw): cmd = _pre_call(args) try: return _check_output(args, stdin=stdin, stderr=stderr, shell=shell, cwd=cwd, env=env, *popenargs, **popenkw) except CalledProcessError as e: get_logger().debug( "Command %s returned exit code %s. This is the programs output:\n%s<<EOF>>" % (cmd, e.returncode, e.output)) raise
def check_output(cmd): try: return _check_output(cmd) except: return None
import re import logging from subprocess import Popen, PIPE, CalledProcessError, check_output as _check_output from dummy import config from dummy.utils import io __all__ = ("parse", "baseline") logger = logging.getLogger(__name__) # alias check_output to not pipe to stdout check_output = lambda cmd: _check_output(cmd, stderr=PIPE) class LcovError(Exception): pass class Parser: rheader = re.compile(r'^TN:(?P<name>.*)$') rfooter = re.compile(r'^end_of_record$') rpath = re.compile(r'^SF:(?P<path>.*)$') rfunction_hits = re.compile(r'^FNDA:(?P<hits>\d+),(?P<name>.*)$') rfunctions_found = re.compile(r'^FNF:(?P<found>\d+)$') rfunctions_hit = re.compile(r'^FNH:(?P<hits>\d+)$') rlines_found = re.compile(r'^LF:(?P<found>\d+)$') rlines_hit = re.compile(r'^LH:(?P<hits>\d+)$') @staticmethod def parse(info):
def check_output(self, command): log.info('Running command: %s' % ' '.join(command)) output = _check_output(command) log.info(output) return output
import re import logging from subprocess import Popen, PIPE, CalledProcessError, check_output as _check_output from dummy import config from dummy.utils import io __all__ = ( "parse", "baseline" ) logger = logging.getLogger( __name__ ) # alias check_output to not pipe to stdout check_output = lambda cmd: _check_output( cmd, stderr=PIPE ) class LcovError( Exception ): pass class Parser: rheader = re.compile( r'^TN:(?P<name>.*)$' ) rfooter = re.compile( r'^end_of_record$' ) rpath = re.compile( r'^SF:(?P<path>.*)$' ) rfunction_hits = re.compile( r'^FNDA:(?P<hits>\d+),(?P<name>.*)$' ) rfunctions_found= re.compile( r'^FNF:(?P<found>\d+)$' ) rfunctions_hit = re.compile( r'^FNH:(?P<hits>\d+)$' ) rlines_found = re.compile( r'^LF:(?P<found>\d+)$' ) rlines_hit = re.compile( r'^LH:(?P<hits>\d+)$' ) @staticmethod def parse( info ): """ Parses lcov info file into a dictionary args:
def check_output(*args, **kwargs): try: return _check_output(*args, **kwargs) except CalledProcessError as e: raise UserFacingError(e)
def check_output(args: List[Any]) -> bytes: args = args if not IS_WINDOWS else ['powershell'] + args return _check_output(args)
def check_output(*args, **kw): return _check_output(*args, **dict(kw, stderr=kw.get('stderr', PIPE)))
def check_output(args, cwd='.', raise_=True): try: return _check_output(args, cwd=cwd, env=os.environ).decode() except Exception as e: if raise_: raise errors.BinstarError('Failed on {}'.format(args))