Guest User

Untitled

a guest
Sep 12th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. import pysftp
  2.  
  3.  
  4. dbfs_path = '/dbfs/mnt/aaa/bbb/output/{}/'.format(dbutils.widgets.get("run_name"))
  5. remote_path = '/mst_bbb/{}/output/{}/'.format(bucket,dbutils.widgets.get("run_name"))
  6. cnopts = pysftp.CnOpts()
  7. cnopts.hostkeys = None
  8.  
  9. srv = pysftp.Connection(host=host_name, username="xxx",password="yyy",cnopts=cnopts)
  10.  
  11. srv.get_r(remote_path,dbfs_path)
  12.  
  13. import shutil
  14. shutil.rmtree(dbfs_path)
  15.  
  16. ---------------------------------------------------------------------------
  17. IOError Traceback (most recent call last)
  18. <ipython-input-16-9f782d79e03f> in <module>()
  19. 12
  20. 13 srv = pysftp.Connection(host=host_name, username="xxx",password="yyy",cnopts=cnopts)
  21. ---> 14 srv.get_r(remote_path,dbfs_path)
  22.  
  23. /databricks/python/local/lib/python2.7/site-packages/pysftp/__init__.pyc in get_r(self, remotedir, localdir, preserve_mtime)
  24. 309 self.get(fname,
  25. 310 reparent(localdir, fname),
  26. --> 311 preserve_mtime=preserve_mtime)
  27. 312
  28. 313 def getfo(self, remotepath, flo, callback=None):
  29.  
  30. /databricks/python/local/lib/python2.7/site-packages/pysftp/__init__.pyc in get(self, remotepath, localpath, callback, preserve_mtime)
  31. 247 sftpattrs = self._sftp.stat(remotepath)
  32. 248
  33. --> 249 self._sftp.get(remotepath, localpath, callback=callback)
  34. 250 if preserve_mtime:
  35. 251 os.utime(localpath, (sftpattrs.st_atime, sftpattrs.st_mtime))
  36.  
  37. /databricks/python/local/lib/python2.7/site-packages/paramiko/sftp_client.pyc in get(self, remotepath, localpath, callback)
  38. 767 Added the ``callback`` param
  39. 768 """
  40. --> 769 with open(localpath, 'wb') as fl:
  41. 770 size = self.getfo(remotepath, fl, callback)
  42. 771 s = os.stat(localpath)
  43.  
  44. 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