Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement progress bar in rsync #11

Open
alessandrobessi opened this issue Oct 23, 2018 · 1 comment
Open

Implement progress bar in rsync #11

alessandrobessi opened this issue Oct 23, 2018 · 1 comment
Assignees

Comments

@alessandrobessi
Copy link
Member

It would be useful to have a progress bar in rsync. The following code partially solves the problem

from tqdm import tqdm
for stdout_line in tqdm(iter(popen.stdout.readline, "")):
    ...

Indeed, when tqdm is applied to iterators it just shows the number of iterations per second and the elapsed time, unless you specify the parameter total indicating the expected number of iterations.

One could estimate the number of files contained in the src folder, and use the following code:

import os
from tqdm import tqdm
num_files = len([f for f in os.listdir(src) if os.path.isfile(os.path.join(src, f))])
for stdout_line in tqdm(iter(popen.stdout.readline, ""), total=num_files):
    ...

What do you think?

@rpadovani
Copy link
Contributor

Actually I think there is a simpler solution: https://stackoverflow.com/questions/7157973/monitoring-rsync-progress#7272339

I'll have a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants