def __init__( self, path: str, branch: Optional[str] = None, component=None, local: bool = False, skip_init: bool = False, ): self.path = path if branch is None: self.branch = self.default_branch else: self.branch = branch self.component = component self.last_output = "" base_path = self.path.rstrip("/").rstrip("\\") self.lock = WeblateLock( lock_path=os.path.dirname(base_path), scope="repo", key=component.pk if component else os.path.basename(base_path), slug=os.path.basename(base_path), file_template="{slug}.lock", timeout=120, ) self.local = local if not local: # Create ssh wrapper for possible use SSH_WRAPPER.create() if not skip_init and not self.is_valid(): self.init()
def clone(cls, source: str, target: str, branch: Optional[str] = None, component=None): """Clone repository and return object for cloned repository.""" SSH_WRAPPER.create() cls._clone(source, target, branch) return cls(target, branch, component)
def borg(cmd, env=None): """Wrapper to execute borgbackup.""" SSH_WRAPPER.create() try: return subprocess.check_output( ["borg", "--rsh", SSH_WRAPPER.filename] + cmd, stderr=subprocess.STDOUT, env=get_clean_env(env), ).decode("utf-8") except EnvironmentError as error: report_error(error) raise BackupError("Could not execute borg program: {}".format(error)) except subprocess.CalledProcessError as error: report_error(error, extra_data={'stdout': error.stdout.decode("utf-8")}) raise BackupError(error.stdout.decode("utf-8"))
def __init__(self, path, branch=None, component=None, local=False): self.path = path if branch is None: self.branch = self.default_branch else: self.branch = branch self.component = component self.last_output = "" self.lock = FileLock(self.path.rstrip("/").rstrip("\\") + ".lock", timeout=120) self.local = local if not local: # Create ssh wrapper for possible use SSH_WRAPPER.create() if not self.is_valid(): self.init()
def borg(cmd, env=None): """Wrapper to execute borgbackup.""" SSH_WRAPPER.create() try: return subprocess.check_output( ["borg", "--rsh", SSH_WRAPPER.filename] + cmd, stderr=subprocess.STDOUT, env=get_clean_env(env), universal_newlines=True, ) except EnvironmentError as error: report_error() raise BackupError("Could not execute borg program: {}".format(error)) except subprocess.CalledProcessError as error: report_error(extra_data={"stdout": error.stdout}) raise BackupError(error.stdout)
def __init__(self, path, branch=None, component=None, local=False): self.path = path if branch is None: self.branch = self.default_branch else: self.branch = branch self.component = component self.last_output = '' self.lock = FileLock( self.path.rstrip('/').rstrip('\\') + '.lock', timeout=120 ) self.local = local if not local: # Create ssh wrapper for possible use SSH_WRAPPER.create() if not self.is_valid(): self.init()
def borg(cmd, env=None): """Wrapper to execute borgbackup.""" with backup_lock(): SSH_WRAPPER.create() try: return subprocess.check_output( ["borg", "--rsh", SSH_WRAPPER.filename] + cmd, stderr=subprocess.STDOUT, env=get_clean_env(env), universal_newlines=True, ) except OSError as error: report_error() raise BackupError(f"Could not execute borg program: {error}") except subprocess.CalledProcessError as error: add_breadcrumb(category="backup", message="borg output", stdout=error.stdout) report_error() raise BackupError(error.stdout)
def clone(cls, source, target, branch=None): """Clone repository and return object for cloned repository.""" SSH_WRAPPER.create() cls._clone(source, target, branch) return cls(target, branch)
def clone(cls, source, target, branch=None): """Clone repository and return object for cloned repository.""" SSH_WRAPPER.create() cls._clone(source, target, branch) return cls(target, branch)