Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import asyncio, asyncssh, sys
  2. import string
  3. from tqdm import tqdm
  4. from time import sleep
  5. import progressbar
  6.  
  7. pbar = tqdm(unit='B', unit_scale=True, unit_divisor=1024,)
  8.  
  9. def progress(srcpath, dstpath, bytes_copied, total_bytes):
  10. pbar.total = total_bytes
  11. pbar.update(bytes_copied)
  12.  
  13.  
  14.  
  15.  
  16. async def run_client():
  17.  
  18. async with asyncssh.connect('=', username='', port= ) as conn:
  19. async with conn.start_sftp_client() as sftp:
  20. await sftp.mput('TFOLDER ', progress_handler = progress, recurse = True)
  21.  
  22.  
  23. try:
  24. asyncio.get_event_loop().run_until_complete(run_client())
  25. except (OSError, asyncssh.Error) as exc:
  26. sys.exit('SFTP operation failed: ' + str(exc))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement