Adding a progress callback to fabric.operations.put()
See original GitHub issueDescription
Utilizes the existing callback functionallity of paramiko. Considered adding a with_progress flag, but decided to leave it abstract so users can implement their own progress indicator
The arguments for the callback (positional only) are: file name, bytes transferred so far, total bytes to transfer. Including file name in there allows this to be used with sftp.put_dir as well as just sftp.put
Example Usage (with progressbar.ProgressBar):
fname = "my-big-file.tar.gz"
pbar = progressbar.ProgressBar(maxval=os.path.getsize(fname))
def progress_cb(name, done, total):
if pbar.start_time is None:
pbar.start()
pbar.update(done)
put(fname, remote_path, callback=progress_cb)
pbar.finish()
Example Output:
$ fab -H my-host my_task:some,args
[my-host] Executing task 'my_task'
[my-host] put:
/home/mumrah/my-big-file.tar.gz
-> /tmp/my-big-file.tar.gz
9% |#########
Can be useful for large transfers
Originally submitted by David Arthur (mumrah) on 2011-07-23 at 04:44pm EDT
Attachments
Relations
- Related to #236: Add download/upload information for operations get/put
Issue Analytics
- State:
- Created 12 years ago
- Reactions:4
- Comments:55 (1 by maintainers)
Top Results From Across the Web
Developers - Adding a progress callback to fabric.operations.put() -
Description. Utilizes the existing callback functionallity of paramiko. Considered adding a with_progress flag, but decided to leave it abstract so users
Read more >Operations - Fabric documentation
Functions to be used in fabfiles and other non-core code, such as run()/sudo(). fabric.operations. get (remote_path, local_path=None, use_sudo=False, ...
Read more >Fabric - Read the Docs
Fabric is a high level Python (2.7, 3.4+) library designed to execute shell commands remotely over SSH, yielding useful.
Read more >Fabric directory copy with status of copying - Stack Overflow
you could just put print instead of progressbar in the callback. · But put by default does not accept any parameter called callback....
Read more >Python tqdm Module | How to create a terminal progress bar
In the above code, we have set attribute as 100. The called function incremented by ten in each iteration until 100% is achieved....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1
+1