def upload(self, src, dst): if isinstance(src, RemotePath): raise TypeError("src of upload cannot be %r" % (src,)) if isinstance(dst, LocalPath): raise TypeError("dst of upload cannot be %r" % (dst,)) if isinstance(dst, RemotePath) and dst.remote != self: raise TypeError("dst %r points to a different remote machine" % (dst,)) return self._upload(src if isinstance(src, LocalPath) else LocalPath(src), dst if isinstance(dst, RemotePath) else self.path(dst))
def path(self, *parts): """A factory for :class:`LocalPaths <plumbum.path.local.LocalPath>`. Usage: ``p = local.path("/usr", "lib", "python2.7")`` """ parts2 = [str(self.cwd)] for p in parts: if isinstance(p, RemotePath): raise TypeError("Cannot construct LocalPath from %r" % (p,)) parts2.append(self.env.expanduser(str(p))) return LocalPath(os.path.join(*parts2))
def upload(self, src, dst): if isinstance(src, RemotePath): raise TypeError(f"src of upload cannot be {src!r}") if isinstance(dst, LocalPath): raise TypeError(f"dst of upload cannot be {dst!r}") if isinstance(dst, RemotePath) and dst.remote != self: raise TypeError(f"dst {dst!r} points to a different remote machine") return self._upload( src if isinstance(src, LocalPath) else LocalPath(src), dst if isinstance(dst, RemotePath) else self.path(dst), )
def download(self, src, dst): if isinstance(src, LocalPath): raise TypeError("src of download cannot be {!r}".format(src)) if isinstance(src, RemotePath) and src.remote != self: raise TypeError( "src {!r} points to a different remote machine".format(src)) if isinstance(dst, RemotePath): raise TypeError("dst of download cannot be {!r}".format(dst)) return self._download( src if isinstance(src, RemotePath) else self.path(src), dst if isinstance(dst, LocalPath) else LocalPath(dst), )
def rel(path: LocalPath): return path.relative_to(local.path('.'))
def _teardown(self, name: str): if LocalPath('gen/%s-dc.yml' % name).exists(): self.tools_dc(name, 'down')
def _collect_logs(self, name: str): if LocalPath('gen/%s-dc.yml' % name).exists(): self.tools_dc('collect_logs', name, self.artifacts / 'logs' / 'docker')