Merge lp:~savoirfairelinux-openerp/lp-community-utils/progressbar into lp:lp-community-utils

Status: Merged
Merged at revision: 24
Proposed branch: lp:~savoirfairelinux-openerp/lp-community-utils/progressbar
Merge into: lp:lp-community-utils
Diff against target: 52 lines (+15/-0)
2 files modified
README.rst (+2/-0)
openerp-nag (+13/-0)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/lp-community-utils/progressbar
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Maxime Chambreuil (http://www.savoirfairelinux.com) Approve
Pedro Manuel Baeza code review and test Approve
Review via email: mp+205252@code.launchpad.net

Description of the change

Adds a progressbar in the console output since this script takes a long time.
The progressbar is from the progressbar library. If it is available, it will offer it, otherwise, it will go on as before.

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

It doesn't work with the version included in Ubuntu 12.04 (python-progressbar 2.2-2), but it does with the one got with pip. It says:

"'ProgressBar' object is not callable"

Do you know what can be happening?

Regards.

review: Needs Information
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

I didn't test with version 2.2, I assumed it would work.
What version do you have with pip?

The version I used (I have Arch, not Ubuntu) is 2.3.

This is the base usage of progressbar (from their documentation)
progress = ProgressBar()
for i in progress(range(80)):
  time.sleep(0.01)

The problematic call would be progress(...)

Maybe this is a functionality introduced by 2.3

25. By Sandy Carter (http://www.savoirfairelinux.com)

Made progressbar=2.2 compatible

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Sandy,

Now, it works well with both versions.

Thank you very much.

Regards.

review: Approve (code review and test)
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Nice!
Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.rst'
2--- README.rst 2013-09-22 14:36:16 +0000
3+++ README.rst 2014-02-06 21:02:36 +0000
4@@ -8,6 +8,7 @@
5 Other versions of Python have not been tested.
6
7 The launchpadlib_ egg is required.
8+The progressbar_ library is optional but allows to display progress
9
10 Usage
11 -----
12@@ -61,5 +62,6 @@
13
14
15 .. _launchpadlib: http://pypi.python.org/pypi/launchpadlib/1.10.2
16+.. _progressbar: https://pypi.python.org/pypi/progressbar/2.2
17 .. _lazr.restfulclient: https://launchpad.net/lazr.restfulclient
18 .. _lazr.restfulclient bug report: https://bugs.launchpad.net/lazr.restfulclient/+bug/1094253
19
20=== modified file 'openerp-nag'
21--- openerp-nag 2013-09-22 14:36:16 +0000
22+++ openerp-nag 2014-02-06 21:02:36 +0000
23@@ -46,6 +46,10 @@
24 import datetime
25 import logging
26
27+try:
28+ from progressbar import ProgressBar, Bar, Percentage, ETA
29+except ImportError:
30+ ProgressBar = None
31 from launchpadlib.launchpad import Launchpad
32
33
34@@ -227,9 +231,18 @@
35
36 # Find things to nag about
37 nags = []
38+ if ProgressBar:
39+ widgets = ["Looking for things to nag about... ", Percentage(),
40+ Bar(left=" [", right="] "), ETA()]
41+ progress = ProgressBar(widgets=widgets, maxval=len(project_names)).start()
42 for project_name in project_names:
43 logging.info("Looking for things to nag about under %s", project_name)
44 nags.extend(gen_project_nags(lp, policy, project_name))
45+ if ProgressBar:
46+ progress.update(progress.currval + 1)
47+ if ProgressBar:
48+ progress.finish()
49+
50 nags.sort(key=lambda nag: (nag.sort_class, nag.sort_priority,
51 nag.sort_age))
52 print("=" * 80)

Subscribers

People subscribed via source and target branches