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
=== modified file 'utils/piston-helpers/piston_generic_helper.py'
--- utils/piston-helpers/piston_generic_helper.py 2012-04-25 08:15:28 +0000
+++ utils/piston-helpers/piston_generic_helper.py 2012-05-25 12:28:29 +0000
@@ -159,6 +159,9 @@
159 help="setup alternative datadir")159 help="setup alternative datadir")
160 parser.add_argument("--ignore-cache", action="store_true", default=False,160 parser.add_argument("--ignore-cache", action="store_true", default=False,
161 help="force ignore cache")161 help="force ignore cache")
162 parser.add_argument("--disable-offline-mode", action="store_true",
163 default=False,
164 help="force disable offline mode")
162 parser.add_argument("--needs-auth", default=False, action="store_true",165 parser.add_argument("--needs-auth", default=False, action="store_true",
163 help="need oauth credentials")166 help="need oauth credentials")
164 parser.add_argument("--output", default="pickle",167 parser.add_argument("--output", default="pickle",
@@ -213,8 +216,14 @@
213 try:216 try:
214 piston_reply = f(**kwargs)217 piston_reply = f(**kwargs)
215 except httplib2.ServerNotFoundError as e:218 except httplib2.ServerNotFoundError as e:
216 LOG.warn(e)219 if not args.disable_offline_mode:
217 sys.exit(1)220 # switch to offline mode and try again from the cache
221 try:
222 api._offline_mode = True
223 piston_reply = f(**kwargs)
224 except Exception as e:
225 LOG.warn(e)
226 sys.exit(1)
218 except APIError as e:227 except APIError as e:
219 LOG.warn(e)228 LOG.warn(e)
220 sys.exit(1)229 sys.exit(1)

Subscribers

People subscribed via source and target branches