コード例 #1
0
ファイル: SFTP.py プロジェクト: vodkatad/snakemake_docker
 def exists(self):
     if self._matched_address:
         with self.sftpc() as sftpc:
             return sftpc.exists(self.remote_path)
             if sftpc.exists(self.remote_path):
                 return sftpc.isfile(self.remote_path)
         return False
     else:
         raise SFTPFileException(
             "The file cannot be parsed as an SFTP path in form 'host:port/path/to/file': %s"
             % self.local_file())
コード例 #2
0
    def download(self, make_dest_dirs=True):
        with self.sftpc() as sftpc:
            if self.exists():
                # if the destination path does not exist
                if make_dest_dirs:
                    os.makedirs(os.path.dirname(self.local_path),
                                exist_ok=True)

                sftpc.get(remotepath=self.remote_path,
                          localpath=self.local_path,
                          preserve_mtime=True)
            else:
                raise SFTPFileException(
                    "The file does not seem to exist remotely: %s" %
                    self.file())
コード例 #3
0
ファイル: SFTP.py プロジェクト: fdchevalier/snakemake
    def download(self, make_dest_dirs=True):
        with self.connection_pool.item() as sftpc:
            if self.exists():
                # if the destination path does not exist
                if make_dest_dirs:
                    os.makedirs(os.path.dirname(self.local_path), exist_ok=True)

                sftpc.get(
                    remotepath=self.remote_path,
                    localpath=self.local_path,
                    preserve_mtime=True,
                )
                os_sync()  # ensure flush to disk
            else:
                raise SFTPFileException(
                    "The file does not seem to exist remotely: %s" % self.local_file()
                )