예제 #1
0
파일: ssh.py 프로젝트: AinuX/spur.py
 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)
예제 #2
0
파일: ssh.py 프로젝트: ii0/spur.py
    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)
예제 #3
0
 def temporary_dir(self):
     return create_temporary_dir()
예제 #4
0
 def temporary_dir(self):
     return create_temporary_dir()