def upload_dir(self, local_dir, remote_dir, ignore): with create_temporary_dir() as temp_dir: content_tarball_path = os.path.join(temp_dir, "content.tar.gz") content_path = os.path.join(temp_dir, "content") shutil.copytree(local_dir, content_path, ignore=shutil.ignore_patterns(*ignore)) subprocess.check_call( ["tar", "czf", content_tarball_path, "content"], cwd=temp_dir ) with self._connect_sftp() as sftp: remote_tarball_path = "/tmp/{0}.tar.gz".format(uuid.uuid4()) sftp.put(content_tarball_path, remote_tarball_path) self.run(["mkdir", "-p", remote_dir]) self.run([ "tar", "xzf", remote_tarball_path, "--strip-components", "1", "--directory", remote_dir ]) sftp.remove(remote_tarball_path)
def upload_dir(self, local_dir, remote_dir, ignore): with create_temporary_dir() as temp_dir: content_tarball_path = os.path.join(temp_dir, "content.tar.gz") content_path = os.path.join(temp_dir, "content") shutil.copytree(local_dir, content_path, ignore=shutil.ignore_patterns(*ignore)) subprocess.check_call( ["tar", "czf", content_tarball_path, "content"], cwd=temp_dir) with self._connect_sftp() as sftp: remote_tarball_path = "/tmp/{0}.tar.gz".format(uuid.uuid4()) sftp.put(content_tarball_path, remote_tarball_path) self.run(["mkdir", "-p", remote_dir]) self.run([ "tar", "xzf", remote_tarball_path, "--strip-components", "1", "--directory", remote_dir ]) sftp.remove(remote_tarball_path)
def temporary_dir(self): return create_temporary_dir()