Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pysftp
- dbfs_path = '/dbfs/mnt/aaa/bbb/output/{}/'.format(dbutils.widgets.get("run_name"))
- remote_path = '/mst_bbb/{}/output/{}/'.format(bucket,dbutils.widgets.get("run_name"))
- cnopts = pysftp.CnOpts()
- cnopts.hostkeys = None
- srv = pysftp.Connection(host=host_name, username="xxx",password="yyy",cnopts=cnopts)
- srv.get_r(remote_path,dbfs_path)
- import shutil
- shutil.rmtree(dbfs_path)
- ---------------------------------------------------------------------------
- IOError Traceback (most recent call last)
- <ipython-input-16-9f782d79e03f> in <module>()
- 12
- 13 srv = pysftp.Connection(host=host_name, username="xxx",password="yyy",cnopts=cnopts)
- ---> 14 srv.get_r(remote_path,dbfs_path)
- /databricks/python/local/lib/python2.7/site-packages/pysftp/__init__.pyc in get_r(self, remotedir, localdir, preserve_mtime)
- 309 self.get(fname,
- 310 reparent(localdir, fname),
- --> 311 preserve_mtime=preserve_mtime)
- 312
- 313 def getfo(self, remotepath, flo, callback=None):
- /databricks/python/local/lib/python2.7/site-packages/pysftp/__init__.pyc in get(self, remotepath, localpath, callback, preserve_mtime)
- 247 sftpattrs = self._sftp.stat(remotepath)
- 248
- --> 249 self._sftp.get(remotepath, localpath, callback=callback)
- 250 if preserve_mtime:
- 251 os.utime(localpath, (sftpattrs.st_atime, sftpattrs.st_mtime))
- /databricks/python/local/lib/python2.7/site-packages/paramiko/sftp_client.pyc in get(self, remotepath, localpath, callback)
- 767 Added the ``callback`` param
- 768 """
- --> 769 with open(localpath, 'wb') as fl:
- 770 size = self.getfo(remotepath, fl, callback)
- 771 s = os.stat(localpath)
- IOError: [Errno 2] No such file or directory: u'/dbfs/aaa/bbb/output/run_job/./mst_bbb/pri1/output/run_job/date=2017-12-01/2017-12-01_output_0.csv.gz'
Add Comment
Please, Sign In to add comment