Merge lp:~mvo/software-center/piston-generic-helper-offline-mode into lp:software-center

Proposed by Michael Vogt on 2012-05-25
Status: Merged
Merged at revision: 3022
Proposed branch: lp:~mvo/software-center/piston-generic-helper-offline-mode
Merge into: lp:software-center
Diff against target: 30 lines (+11/-2)
1 file modified
utils/piston-helpers/piston_generic_helper.py (+11/-2)
To merge this branch: bzr merge lp:~mvo/software-center/piston-generic-helper-offline-mode
Reviewer Review Type Date Requested Status
Gary Lasker (community) 2012-05-25 Approve on 2012-05-31
Review via email: mp+107362@code.launchpad.net

Description of the change

Tiny branch that adds support for offline mode to the generic-helper just like for the piston_get_reviews_helper.py

Note that we could backport this at some point, but we need to be careful about regressions (I can't think
of any currently, but that does not mean anything ;)

To post a comment you must log in.
Gary Lasker (gary-lasker) wrote :

Very cool! I can see lobby recommendations now even when offline. This is a great kickoff to building up a nicely effective offline experience. Thanks Michael!

I'll merge this to trunk, and we can decide about backporting later.

review: Approve
Gary Lasker (gary-lasker) wrote :

...effective offline *recommendations* experience, to be more specific.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utils/piston-helpers/piston_generic_helper.py'
2--- utils/piston-helpers/piston_generic_helper.py 2012-04-25 08:15:28 +0000
3+++ utils/piston-helpers/piston_generic_helper.py 2012-05-25 12:28:29 +0000
4@@ -159,6 +159,9 @@
5 help="setup alternative datadir")
6 parser.add_argument("--ignore-cache", action="store_true", default=False,
7 help="force ignore cache")
8+ parser.add_argument("--disable-offline-mode", action="store_true",
9+ default=False,
10+ help="force disable offline mode")
11 parser.add_argument("--needs-auth", default=False, action="store_true",
12 help="need oauth credentials")
13 parser.add_argument("--output", default="pickle",
14@@ -213,8 +216,14 @@
15 try:
16 piston_reply = f(**kwargs)
17 except httplib2.ServerNotFoundError as e:
18- LOG.warn(e)
19- sys.exit(1)
20+ if not args.disable_offline_mode:
21+ # switch to offline mode and try again from the cache
22+ try:
23+ api._offline_mode = True
24+ piston_reply = f(**kwargs)
25+ except Exception as e:
26+ LOG.warn(e)
27+ sys.exit(1)
28 except APIError as e:
29 LOG.warn(e)
30 sys.exit(1)

Subscribers

People subscribed via source and target branches