question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding a progress callback to fabric.operations.put()

See original GitHub issue

Description

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:open
  • Created 12 years ago
  • Reactions:4
  • Comments:55 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sxalexandercommented, Sep 15, 2012

+1

0reactions
embassemcommented, Sep 5, 2016

+1

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found