def check_call(*args, **kwargs): """Return whether call was successful.""" try: _check_call(*args, **kwargs) except CalledProcessError, error: log.warn(error) return False
def _resolve_conflict_via_command(a, b, command, a_name, b_name, _check_call=None): import tempfile import shutil if _check_call is None: from subprocess import check_call as _check_call from ..vobject import Item dir = tempfile.mkdtemp(prefix='vdirsyncer-conflict.') try: a_tmp = os.path.join(dir, a_name) b_tmp = os.path.join(dir, b_name) with open(a_tmp, 'w') as f: f.write(a.raw) with open(b_tmp, 'w') as f: f.write(b.raw) command[0] = expand_path(command[0]) _check_call(command + [a_tmp, b_tmp]) with open(a_tmp) as f: new_a = f.read() with open(b_tmp) as f: new_b = f.read() if new_a != new_b: raise exceptions.UserError('The two files are not completely ' 'equal.') return Item(new_a) finally: shutil.rmtree(dir)
def check_call(cmd: List[str], *args: Any, **kwargs: Any) -> None: shlexed = " ".join([shlex.quote(x) for x in cmd]) logging.trace("Running '%s'", shlexed) _QCMD_LOGGER.info(shlexed) try: _check_call(cmd, *args, **kwargs) except Exception as e: logging.error("'%s' failed: %s", shlexed, str(e)) _QCMD_LOGGER.error(">> %s", str(e)) raise
def _cap_call(cmd, retry, _raise, _test=False): out = tempfile.TemporaryFile() err = tempfile.TemporaryFile() res = True try: logging.info('_cap_call: %s', str(cmd)) _check_call(cmd, shell=True, stdout=out, stderr=err) except CalledProcessError, e: logging.error(str(e)) res = False if _raise: raise
def check_call(args, stdin=None, stdout=None, stderr=None, shell=False, cwd=None, env=None, *popenargs, **popenkw): cmd = _pre_call(args) try: return _check_call(args, stdin=stdin, stdout=stdout, stderr=stderr, shell=shell, cwd=cwd, env=env, *popenargs, **popenkw) except CalledProcessError as e: get_logger().debug("Command %s returned exit code %s." % (cmd, e.returncode)) raise
def check_call(args, stdin=None, stdout=None, stderr=None, shell=False, cwd=None, env=None, *popenargs, **popenkw): cmd = _pre_call(args) try: return _check_call( args, stdin=stdin, stdout=stdout, stderr=stderr, shell=shell, cwd=cwd, env=env, *popenargs, **popenkw ) except CalledProcessError, e: get_logger().debug("Command %s returned exit code %s." % (cmd, e.returncode)) raise
def check_call(cmd, **kwargs): print 'check_call:' print ' '.join(cmd) if isinstance(cmd, list) else cmd print return _check_call(cmd, **kwargs)
def check_call(cmd, *args, **kwargs): cmdstr = cmd if isinstance(cmd, basestring) else ' '.join(cmd) print_log(cmdstr) return _check_call(cmd, *args, **kwargs)
def check_call(cmd_args, *args, **kwargs): rc = _check_call(cmd_args, *args, **kwargs) print("", COLOR.BOLD, " ".join(args), COLOR.ENDC) return rc
def check_call(cmd, *args, **kwargs): cmdstr = cmd if isinstance(cmd, string_types) else ' '.join(cmd) print_log(cmdstr) return _check_call(cmd, *args, **kwargs)
def check_call(*args, **kwargs): try: _check_call(*args, **kwargs) except CalledProcessError as e: raise UserFacingError(e)
def check_call(cmd, *args, **kwargs): log.info("$ %s" % " ".join(cmd)) return _check_call(cmd, *args, **kwargs)