def run(*args, **kwargs): """A wrapper to Fabric's run/sudo commands that takes into account the mode_local. """ ret = [] if "force" in kwargs: force = kwargs["force"] del kwargs["force"] else: force = False if is_local(): if is_sudo(): kwargs.setdefault("sudo", True) _exes = execute(run_local, True, *args, **kwargs) else: if is_sudo(): _exes = execute(fabric.api.sudo, True, *args, **kwargs) else: _exes = execute(fabric.api.run, True, *args, **kwargs) for k, _exe in _exes.items(): if _exe.return_code != 0 and not force: raise ExecutionError( "%s: failed to run '%s' (retcode:%d): '%s'" % (env.host_string, " ".join(args), _exe.return_code, str(_exe))) else: ret.append(_exe) return ret
def run(*args, **kwargs): """A wrapper to Fabric's run/sudo commands that takes into account the mode_local. """ ret = [] if "force" in kwargs: force = kwargs["force"] del kwargs["force"] else: force = False if is_local(): if is_sudo(): kwargs.setdefault("sudo", True) _exes = execute(run_local, True, *args, **kwargs) else: if is_sudo(): _exes = execute(fabric.api.sudo, True, *args, **kwargs) else: _exes = execute(fabric.api.run, True, *args, **kwargs) for k, _exe in _exes.items(): if _exe.return_code != 0 and not force: raise ExecutionError( "%s: failed to run '%s' (retcode:%d): '%s'" % (env.host_string, " ".join(args), _exe.return_code, str(_exe)) ) else: ret.append(_exe) return ret
def label(): if env.get("host_label", False) and \ env.get("host_string", False) and \ env["host_label"][env["host_string"]]: return env["host_label"][env["host_string"]] if env.get("host_string", False): return env["host_string"] if is_local(): return "local" return "cloud"