Merge lp:~elachuni/software-center/pep8-test-part20 into lp:software-center
- pep8-test-part20
- Merge into trunk
Proposed by
Anthony Lenton
Status: | Merged |
---|---|
Merged at revision: | 2874 |
Proposed branch: | lp:~elachuni/software-center/pep8-test-part20 |
Merge into: | lp:software-center |
Prerequisite: | lp:~elachuni/software-center/pep8-test-part19 |
Diff against target: |
1547 lines (+368/-270) 11 files modified
softwarecenter/backend/installbackend_impl/aptd.py (+159/-119) softwarecenter/backend/installbackend_impl/packagekit_enums.py (+4/-2) softwarecenter/backend/installbackend_impl/packagekitd.py (+92/-59) softwarecenter/backend/piston/rnrclient.py (+14/-9) softwarecenter/backend/piston/rnrclient_fake.py (+74/-68) softwarecenter/backend/piston/rnrclient_pristine.py (+8/-3) softwarecenter/backend/piston/scaclient.py (+8/-7) softwarecenter/backend/piston/scaclient_pristine.py (+1/-0) softwarecenter/backend/piston/sreclient_pristine.py (+1/-0) softwarecenter/backend/piston/sso_helper.py (+3/-3) test/test_pep8.py (+4/-0) |
To merge this branch: | bzr merge lp:~elachuni/software-center/pep8-test-part20 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kiwinote | Approve | ||
Review via email: mp+97977@code.launchpad.net |
Commit message
Description of the change
This branch makes all files under softwarecenter/
To post a comment you must log in.
Revision history for this message
Kiwinote (kiwinote) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'softwarecenter/backend/installbackend_impl/aptd.py' |
2 | --- softwarecenter/backend/installbackend_impl/aptd.py 2012-03-16 14:36:05 +0000 |
3 | +++ softwarecenter/backend/installbackend_impl/aptd.py 2012-03-16 20:20:25 +0000 |
4 | @@ -41,7 +41,7 @@ |
5 | |
6 | from softwarecenter.db.application import Application |
7 | from softwarecenter.backend.transactionswatcher import ( |
8 | - BaseTransactionsWatcher, |
9 | + BaseTransactionsWatcher, |
10 | BaseTransaction, |
11 | TransactionFinishedResult, |
12 | TransactionProgress) |
13 | @@ -52,6 +52,8 @@ |
14 | # its important that we only have a single dbus BusConnection |
15 | # per address when using the fake dbus aptd |
16 | buses = {} |
17 | + |
18 | + |
19 | def get_dbus_bus(): |
20 | if "SOFTWARE_CENTER_APTD_FAKE" in os.environ: |
21 | global buses |
22 | @@ -63,6 +65,7 @@ |
23 | bus = dbus.SystemBus() |
24 | return bus |
25 | |
26 | + |
27 | class FakePurchaseTransaction(object): |
28 | def __init__(self, app, iconname): |
29 | self.pkgname = app.pkgname |
30 | @@ -70,6 +73,7 @@ |
31 | self.iconname = iconname |
32 | self.progress = 0 |
33 | |
34 | + |
35 | class AptdaemonTransaction(BaseTransaction): |
36 | def __init__(self, trans): |
37 | self._trans = trans |
38 | @@ -126,9 +130,10 @@ |
39 | trans = AptdaemonTransaction(trans) |
40 | return real_handler(trans, *args) |
41 | |
42 | + |
43 | class AptdaemonTransactionsWatcher(BaseTransactionsWatcher): |
44 | - """ |
45 | - base class for objects that need to watch the aptdaemon |
46 | + """ |
47 | + base class for objects that need to watch the aptdaemon |
48 | for transaction changes. it registers a handler for the daemon |
49 | going away and reconnects when it appears again |
50 | """ |
51 | @@ -144,7 +149,7 @@ |
52 | #print "_register_active_transactions_watch", connection |
53 | bus = get_dbus_bus() |
54 | apt_daemon = client.get_aptdaemon(bus=bus) |
55 | - apt_daemon.connect_to_signal("ActiveTransactionsChanged", |
56 | + apt_daemon.connect_to_signal("ActiveTransactionsChanged", |
57 | self._on_transactions_changed) |
58 | current, queued = apt_daemon.GetActiveTransactions() |
59 | self._on_transactions_changed(current, queued) |
60 | @@ -158,54 +163,54 @@ |
61 | trans = client.get_transaction(tid) |
62 | return AptdaemonTransaction(trans) |
63 | except dbus.DBusException: |
64 | - return None |
65 | + pass |
66 | |
67 | |
68 | class AptdaemonBackend(GObject.GObject, InstallBackend): |
69 | """ software center specific code that interacts with aptdaemon """ |
70 | |
71 | - __gsignals__ = {'transaction-started':(GObject.SIGNAL_RUN_FIRST, |
72 | + __gsignals__ = {'transaction-started': (GObject.SIGNAL_RUN_FIRST, |
73 | GObject.TYPE_NONE, |
74 | - (str,str,str,str)), |
75 | + (str, str, str, str)), |
76 | # emits a TransactionFinished object |
77 | - 'transaction-finished':(GObject.SIGNAL_RUN_FIRST, |
78 | - GObject.TYPE_NONE, |
79 | - (GObject.TYPE_PYOBJECT, )), |
80 | - 'transaction-stopped':(GObject.SIGNAL_RUN_FIRST, |
81 | + 'transaction-finished': (GObject.SIGNAL_RUN_FIRST, |
82 | + GObject.TYPE_NONE, |
83 | + (GObject.TYPE_PYOBJECT, )), |
84 | + 'transaction-stopped': (GObject.SIGNAL_RUN_FIRST, |
85 | GObject.TYPE_NONE, |
86 | (GObject.TYPE_PYOBJECT,)), |
87 | - 'transactions-changed':(GObject.SIGNAL_RUN_FIRST, |
88 | - GObject.TYPE_NONE, |
89 | - (GObject.TYPE_PYOBJECT, )), |
90 | - 'transaction-progress-changed':(GObject.SIGNAL_RUN_FIRST, |
91 | - GObject.TYPE_NONE, |
92 | - (str,int,)), |
93 | + 'transactions-changed': (GObject.SIGNAL_RUN_FIRST, |
94 | + GObject.TYPE_NONE, |
95 | + (GObject.TYPE_PYOBJECT, )), |
96 | + 'transaction-progress-changed': (GObject.SIGNAL_RUN_FIRST, |
97 | + GObject.TYPE_NONE, |
98 | + (str, int,)), |
99 | # the number/names of the available channels changed |
100 | - 'channels-changed':(GObject.SIGNAL_RUN_FIRST, |
101 | + 'channels-changed': (GObject.SIGNAL_RUN_FIRST, |
102 | + GObject.TYPE_NONE, |
103 | + (bool,)), |
104 | + # cache reload emits this specific signal as well |
105 | + 'reload-finished': (GObject.SIGNAL_RUN_FIRST, |
106 | GObject.TYPE_NONE, |
107 | - (bool,)), |
108 | - # cache reload emits this specific signal as well |
109 | - 'reload-finished':(GObject.SIGNAL_RUN_FIRST, |
110 | - GObject.TYPE_NONE, |
111 | - (GObject.TYPE_PYOBJECT, bool,)), |
112 | + (GObject.TYPE_PYOBJECT, bool,)), |
113 | } |
114 | |
115 | def __init__(self): |
116 | GObject.GObject.__init__(self) |
117 | - |
118 | + |
119 | bus = get_dbus_bus() |
120 | self.aptd_client = client.AptClient(bus=bus) |
121 | self.pending_transactions = {} |
122 | self._transactions_watcher = AptdaemonTransactionsWatcher() |
123 | self._transactions_watcher.connect("lowlevel-transactions-changed", |
124 | - self._on_lowlevel_transactions_changed) |
125 | + self._on_lowlevel_transactions_changed) |
126 | # dict of pkgname -> FakePurchaseTransaction |
127 | self.pending_purchases = {} |
128 | self._progress_signal = None |
129 | self._logger = logging.getLogger("softwarecenter.backend") |
130 | # the AptdaemonBackendUI code |
131 | self.ui = None |
132 | - |
133 | + |
134 | def _axi_finished(self, res): |
135 | self.emit("channels-changed", res) |
136 | |
137 | @@ -216,7 +221,7 @@ |
138 | # axi is optional, so just do nothing if its not installed |
139 | try: |
140 | axi = dbus.Interface( |
141 | - system_bus.get_object("org.debian.AptXapianIndex","/"), |
142 | + system_bus.get_object("org.debian.AptXapianIndex", "/"), |
143 | "org.debian.AptXapianIndex") |
144 | except dbus.DBusException as e: |
145 | self._logger.warning("axi can not be updated '%s'" % e) |
146 | @@ -234,22 +239,26 @@ |
147 | def fix_broken_depends(self): |
148 | try: |
149 | trans = yield self.aptd_client.fix_broken_depends(defer=True) |
150 | - self.emit("transaction-started", "", "", trans.tid, TransactionTypes.REPAIR) |
151 | + self.emit("transaction-started", "", "", trans.tid, |
152 | + TransactionTypes.REPAIR) |
153 | yield self._run_transaction(trans, None, None, None) |
154 | except Exception as error: |
155 | self._on_trans_error(error) |
156 | |
157 | # FIXME: upgrade add-ons here |
158 | @inline_callbacks |
159 | - def upgrade(self, app, iconname, addons_install=[], addons_remove=[], metadata=None): |
160 | + def upgrade(self, app, iconname, addons_install=[], addons_remove=[], |
161 | + metadata=None): |
162 | """ upgrade a single package """ |
163 | pkgname = app.pkgname |
164 | appname = app.appname |
165 | try: |
166 | trans = yield self.aptd_client.upgrade_packages([pkgname], |
167 | defer=True) |
168 | - self.emit("transaction-started", pkgname, appname, trans.tid, TransactionTypes.UPGRADE) |
169 | - yield self._run_transaction(trans, pkgname, appname, iconname, metadata) |
170 | + self.emit("transaction-started", pkgname, appname, trans.tid, |
171 | + TransactionTypes.UPGRADE) |
172 | + yield self._run_transaction(trans, pkgname, appname, iconname, |
173 | + metadata) |
174 | except Exception as error: |
175 | self._on_trans_error(error, pkgname) |
176 | |
177 | @@ -257,9 +266,10 @@ |
178 | # @inline_callbacks |
179 | # def _simulate_remove_multiple(self, pkgnames): |
180 | # try: |
181 | -# trans = yield self.aptd_client.remove_packages(pkgnames, |
182 | +# trans = yield self.aptd_client.remove_packages(pkgnames, |
183 | # defer=True) |
184 | -# trans.connect("dependencies-changed", self._on_dependencies_changed) |
185 | +# trans.connect("dependencies-changed", |
186 | +# self._on_dependencies_changed) |
187 | # except Exception: |
188 | # logging.exception("simulate_remove") |
189 | # return_value(trans) |
190 | @@ -278,22 +288,25 @@ |
191 | # gtk.main_iteration() |
192 | # time.sleep(0.01) |
193 | |
194 | - |
195 | @inline_callbacks |
196 | - def remove(self, app, iconname, addons_install=[], addons_remove=[], metadata=None): |
197 | + def remove(self, app, iconname, addons_install=[], addons_remove=[], |
198 | + metadata=None): |
199 | """ remove a single package """ |
200 | pkgname = app.pkgname |
201 | appname = app.appname |
202 | try: |
203 | trans = yield self.aptd_client.remove_packages([pkgname], |
204 | defer=True) |
205 | - self.emit("transaction-started", pkgname, appname, trans.tid, TransactionTypes.REMOVE) |
206 | - yield self._run_transaction(trans, pkgname, appname, iconname, metadata) |
207 | + self.emit("transaction-started", pkgname, appname, trans.tid, |
208 | + TransactionTypes.REMOVE) |
209 | + yield self._run_transaction(trans, pkgname, appname, iconname, |
210 | + metadata) |
211 | except Exception as error: |
212 | self._on_trans_error(error, pkgname) |
213 | |
214 | @inline_callbacks |
215 | - def remove_multiple(self, apps, iconnames, addons_install=[], addons_remove=[], metadatas=None): |
216 | + def remove_multiple(self, apps, iconnames, addons_install=[], |
217 | + addons_remove=[], metadatas=None): |
218 | """ queue a list of packages for removal """ |
219 | if metadatas == None: |
220 | metadatas = [] |
221 | @@ -303,7 +316,8 @@ |
222 | yield self.remove(app, iconname, metadata) |
223 | |
224 | @inline_callbacks |
225 | - def install(self, app, iconname, filename=None, addons_install=[], addons_remove=[], metadata=None, force=False): |
226 | + def install(self, app, iconname, filename=None, addons_install=[], |
227 | + addons_remove=[], metadata=None, force=False): |
228 | """Install a single package from the archive |
229 | If filename is given a local deb package is installed instead. |
230 | """ |
231 | @@ -317,23 +331,26 @@ |
232 | # force means on lintian failure |
233 | trans = yield self.aptd_client.install_file( |
234 | filename, force=force, defer=True) |
235 | - self.emit("transaction-started", pkgname, appname, trans.tid, TransactionTypes.INSTALL) |
236 | + self.emit("transaction-started", pkgname, appname, trans.tid, |
237 | + TransactionTypes.INSTALL) |
238 | yield trans.set_meta_data(sc_filename=filename, defer=True) |
239 | else: |
240 | install = [pkgname] + addons_install |
241 | remove = addons_remove |
242 | - reinstall = remove = purge = upgrade =downgrade = [] |
243 | + reinstall = remove = purge = upgrade = downgrade = [] |
244 | trans = yield self.aptd_client.commit_packages( |
245 | - install, reinstall, remove, purge, upgrade, downgrade, |
246 | + install, reinstall, remove, purge, upgrade, downgrade, |
247 | defer=True) |
248 | - self.emit("transaction-started", pkgname, appname, trans.tid, TransactionTypes.INSTALL) |
249 | + self.emit("transaction-started", pkgname, appname, trans.tid, |
250 | + TransactionTypes.INSTALL) |
251 | yield self._run_transaction( |
252 | trans, pkgname, appname, iconname, metadata) |
253 | except Exception as error: |
254 | self._on_trans_error(error, pkgname) |
255 | |
256 | @inline_callbacks |
257 | - def install_multiple(self, apps, iconnames, addons_install=[], addons_remove=[], metadatas=None): |
258 | + def install_multiple(self, apps, iconnames, addons_install=[], |
259 | + addons_remove=[], metadatas=None): |
260 | """ queue a list of packages for install """ |
261 | if metadatas == None: |
262 | metadatas = [] |
263 | @@ -341,20 +358,22 @@ |
264 | metadatas.append(None) |
265 | for app, iconname, metadata in zip(apps, iconnames, metadatas): |
266 | yield self.install(app, iconname, metadata=metadata) |
267 | - |
268 | + |
269 | @inline_callbacks |
270 | - def apply_changes(self, app, iconname, addons_install=[], addons_remove=[], metadata=None): |
271 | + def apply_changes(self, app, iconname, addons_install=[], |
272 | + addons_remove=[], metadata=None): |
273 | """ install and remove add-ons """ |
274 | pkgname = app.pkgname |
275 | appname = app.appname |
276 | try: |
277 | install = addons_install |
278 | remove = addons_remove |
279 | - reinstall = remove = purge = upgrade =downgrade = [] |
280 | + reinstall = remove = purge = upgrade = downgrade = [] |
281 | trans = yield self.aptd_client.commit_packages( |
282 | - install, reinstall, remove, purge, upgrade, downgrade, |
283 | + install, reinstall, remove, purge, upgrade, downgrade, |
284 | defer=True) |
285 | - self.emit("transaction-started", pkgname, appname, trans.tid, TransactionTypes.APPLY) |
286 | + self.emit("transaction-started", pkgname, appname, trans.tid, |
287 | + TransactionTypes.APPLY) |
288 | yield self._run_transaction(trans, pkgname, appname, iconname) |
289 | except Exception as error: |
290 | self._on_trans_error(error) |
291 | @@ -365,12 +384,12 @@ |
292 | # check if the sourcespart is there, if not, do a full reload |
293 | # this can happen when the "partner" repository is added, it |
294 | # will be in the main sources.list already and this means that |
295 | - # aptsources will just enable it instead of adding a extra |
296 | + # aptsources will just enable it instead of adding a extra |
297 | # sources.list.d file (LP: #666956) |
298 | d = apt_pkg.config.find_dir("Dir::Etc::sourceparts") |
299 | if (not sources_list or |
300 | not os.path.exists(os.path.join(d, sources_list))): |
301 | - sources_list="" |
302 | + sources_list = "" |
303 | try: |
304 | trans = yield self.aptd_client.update_cache( |
305 | sources_list=sources_list, defer=True) |
306 | @@ -404,18 +423,18 @@ |
307 | continue |
308 | sourcepart = os.path.basename(channelfile) |
309 | yield self.add_sources_list_entry(entry, sourcepart) |
310 | - keyfile = channelfile.replace(".list",".key") |
311 | + keyfile = channelfile.replace(".list", ".key") |
312 | if os.path.exists(keyfile): |
313 | - trans = yield self.aptd_client.add_vendor_key_from_file(keyfile, wait=True) |
314 | + trans = yield self.aptd_client.add_vendor_key_from_file( |
315 | + keyfile, wait=True) |
316 | # don't use self._run_transaction() here, to avoid sending |
317 | # uneeded signals |
318 | yield trans.run(defer=True) |
319 | yield self.reload(sourcepart) |
320 | |
321 | @inline_callbacks |
322 | - def add_vendor_key_from_keyserver(self, keyid, |
323 | - keyserver="hkp://keyserver.ubuntu.com:80/", |
324 | - metadata=None): |
325 | + def add_vendor_key_from_keyserver(self, keyid, |
326 | + keyserver="hkp://keyserver.ubuntu.com:80/", metadata=None): |
327 | # strip the keysize |
328 | if "/" in keyid: |
329 | keyid = keyid.split("/")[1] |
330 | @@ -452,8 +471,8 @@ |
331 | |
332 | @inline_callbacks |
333 | def authenticate_for_purchase(self): |
334 | - """ |
335 | - helper that authenticates with aptdaemon for a purchase operation |
336 | + """ |
337 | + helper that authenticates with aptdaemon for a purchase operation |
338 | """ |
339 | bus = get_dbus_bus() |
340 | name = bus.get_unique_name() |
341 | @@ -462,12 +481,13 @@ |
342 | yield policykit1.check_authorization_by_name(name, action, flags=flags) |
343 | |
344 | @inline_callbacks |
345 | - def add_license_key(self, license_key, license_key_path, license_key_oauth, pkgname): |
346 | + def add_license_key(self, license_key, license_key_path, |
347 | + license_key_oauth, pkgname): |
348 | """ add a license key for a purchase. """ |
349 | self._logger.debug( |
350 | "adding license_key for pkg '%s' of len: %i" % ( |
351 | pkgname, len(license_key))) |
352 | - |
353 | + |
354 | # HOME based license keys |
355 | if license_key_path and license_key_path.startswith("~"): |
356 | # check if its inside HOME and if so, just create it |
357 | @@ -503,19 +523,19 @@ |
358 | license_key_path, |
359 | json_oauth_token=None, |
360 | purchase=True): |
361 | - """ |
362 | + """ |
363 | a convenience method that combines all of the steps needed |
364 | to install a for-pay application, including adding the |
365 | source entry and the vendor key, reloading the package list, |
366 | and finally installing the specified application once the |
367 | package list reload has completed. |
368 | """ |
369 | - self.emit("transaction-started", app.pkgname, app.appname, "FIXME-NEED-ID-HERE", TransactionTypes.INSTALL) |
370 | - self._logger.info("add_repo_add_key_and_install_app() '%s' '%s' '%s'"% ( |
371 | - # re.sub() out the password from the log |
372 | - re.sub("deb https://.*@", "", deb_line), |
373 | - signing_key_id, |
374 | - app)) |
375 | + self.emit("transaction-started", app.pkgname, app.appname, |
376 | + "FIXME-NEED-ID-HERE", TransactionTypes.INSTALL) |
377 | + self._logger.info("add_repo_add_key_and_install_app() '%s' '%s' '%s'" % |
378 | + (re.sub("deb https://.*@", "", deb_line), # strip out password |
379 | + signing_key_id, |
380 | + app)) |
381 | |
382 | if purchase: |
383 | # pre-authenticate |
384 | @@ -537,15 +557,17 @@ |
385 | |
386 | # add the metadata early, add_sources_list_entry is a transaction |
387 | # too |
388 | - trans_metadata = {'sc_add_repo_and_install_appname' : app.appname, |
389 | - 'sc_add_repo_and_install_pkgname' : app.pkgname, |
390 | - 'sc_add_repo_and_install_deb_line' : deb_line, |
391 | - 'sc_iconname' : iconname, |
392 | - 'sc_add_repo_and_install_try' : "1", |
393 | - 'sc_add_repo_and_install_license_key' : license_key or "", |
394 | - 'sc_add_repo_and_install_license_key_path' : license_key_path or "", |
395 | - 'sc_add_repo_and_install_license_key_token' : json_oauth_token or "", |
396 | - } |
397 | + trans_metadata = { |
398 | + 'sc_add_repo_and_install_appname': app.appname, |
399 | + 'sc_add_repo_and_install_pkgname': app.pkgname, |
400 | + 'sc_add_repo_and_install_deb_line': deb_line, |
401 | + 'sc_iconname': iconname, |
402 | + 'sc_add_repo_and_install_try': "1", |
403 | + 'sc_add_repo_and_install_license_key': license_key or "", |
404 | + 'sc_add_repo_and_install_license_key_path': license_key_path or "", |
405 | + 'sc_add_repo_and_install_license_key_token': \ |
406 | + json_oauth_token or "", |
407 | + } |
408 | |
409 | self._logger.info("add_sources_list_entry()") |
410 | sourcepart = yield self.add_sources_list_entry(deb_line) |
411 | @@ -560,8 +582,9 @@ |
412 | yield self._reload_for_commercial_repo(app, trans_metadata, sourcepart) |
413 | |
414 | @inline_callbacks |
415 | - def _reload_for_commercial_repo_defer(self, app, trans_metadata, sources_list): |
416 | - """ |
417 | + def _reload_for_commercial_repo_defer(self, app, trans_metadata, |
418 | + sources_list): |
419 | + """ |
420 | helper that reloads and registers a callback for when the reload is |
421 | finished |
422 | """ |
423 | @@ -570,7 +593,7 @@ |
424 | # otherwise the daemon will fail because he does not know |
425 | # the new package name yet |
426 | self.connect("reload-finished", |
427 | - self._on_reload_for_add_repo_and_install_app_finished, |
428 | + self._on_reload_for_add_repo_and_install_app_finished, |
429 | trans_metadata, app) |
430 | # reload to ensure we have the new package data |
431 | yield self.reload(sources_list=sources_list, metadata=trans_metadata) |
432 | @@ -588,29 +611,34 @@ |
433 | return False |
434 | |
435 | @inline_callbacks |
436 | - def _on_reload_for_add_repo_and_install_app_finished(self, backend, trans, |
437 | - result, metadata, app): |
438 | - """ |
439 | + def _on_reload_for_add_repo_and_install_app_finished(self, backend, trans, |
440 | + result, metadata, app): |
441 | + """ |
442 | callback that is called once after reload was queued |
443 | and will trigger the install of the for-pay package itself |
444 | (after that it will automatically de-register) |
445 | """ |
446 | - #print "_on_reload_for_add_repo_and_install_app_finished", trans, result, backend, self._reload_signal_id |
447 | - self._logger.info("_on_reload_for_add_repo_and_install_app_finished() %s %s %s" % (trans, result, app)) |
448 | + #print "_on_reload_for_add_repo_and_install_app_finished", trans, \ |
449 | + # result, backend, self._reload_signal_id |
450 | + self._logger.info("_on_reload_for_add_repo_and_install_app_finished() " |
451 | + "%s %s %s" % (trans, result, app)) |
452 | |
453 | # check if this is the transaction we waiting for |
454 | key = "sc_add_repo_and_install_pkgname" |
455 | - if not (key in trans.meta_data and trans.meta_data[key] == app.pkgname): |
456 | + if not (key in trans.meta_data and |
457 | + trans.meta_data[key] == app.pkgname): |
458 | return_value(None) |
459 | |
460 | # get the debline and check if we have a release.gpg file |
461 | deb_line = trans.meta_data["sc_add_repo_and_install_deb_line"] |
462 | license_key = trans.meta_data["sc_add_repo_and_install_license_key"] |
463 | - license_key_path = trans.meta_data["sc_add_repo_and_install_license_key_path"] |
464 | - license_key_oauth = trans.meta_data["sc_add_repo_and_install_license_key_token"] |
465 | + license_key_path = trans.meta_data[ |
466 | + "sc_add_repo_and_install_license_key_path"] |
467 | + license_key_oauth = trans.meta_data[ |
468 | + "sc_add_repo_and_install_license_key_token"] |
469 | release_filename = release_filename_in_lists_from_deb_line(deb_line) |
470 | lists_dir = apt_pkg.config.find_dir("Dir::State::lists") |
471 | - release_signature = os.path.join(lists_dir, release_filename)+".gpg" |
472 | + release_signature = os.path.join(lists_dir, release_filename) + ".gpg" |
473 | self._logger.info("looking for '%s'" % release_signature) |
474 | # no Release.gpg in the newly added repository, try again, |
475 | # this can happen e.g. on odd network proxies |
476 | @@ -625,15 +653,15 @@ |
477 | # FIXME: this logic will *fail* if the sources.list of the user |
478 | # was broken before |
479 | |
480 | - # run install action if the repo was added successfully |
481 | + # run install action if the repo was added successfully |
482 | if result: |
483 | self.emit("channels-changed", True) |
484 | |
485 | # we use aptd_client.install_packages() here instead |
486 | - # of just |
487 | + # of just |
488 | # self.install(app, "", metadata=metadata) |
489 | - # go get less authentication prompts (because of the 03_auth_me_less |
490 | - # patch in aptdaemon) |
491 | + # go get less authentication prompts (because of the |
492 | + # 03_auth_me_less patch in aptdaemon) |
493 | try: |
494 | self._logger.info("install_package()") |
495 | trans = yield self.aptd_client.install_packages( |
496 | @@ -648,7 +676,7 @@ |
497 | # but I wonder if we should ease that restriction |
498 | if license_key and not os.path.exists(license_key_path): |
499 | yield self.add_license_key( |
500 | - license_key, license_key_path, license_key_oauth, |
501 | + license_key, license_key_path, license_key_oauth, |
502 | app.pkgname) |
503 | |
504 | else: |
505 | @@ -668,14 +696,16 @@ |
506 | # whole re-try machinery will not survive anyway if the local |
507 | # s-c instance is closed |
508 | self._logger.info("queuing reload in 30s") |
509 | - trans.meta_data["sc_add_repo_and_install_try"]= str(retry+1) |
510 | - sourcepart = trans.meta_data["sc_add_repo_and_install_sources_list"] |
511 | + trans.meta_data["sc_add_repo_and_install_try"] = str(retry + 1) |
512 | + sourcepart = trans.meta_data[ |
513 | + "sc_add_repo_and_install_sources_list"] |
514 | GObject.timeout_add_seconds(30, self._reload_for_commercial_repo, |
515 | app, trans.meta_data, sourcepart) |
516 | |
517 | # internal helpers |
518 | def _on_lowlevel_transactions_changed(self, watcher, current, pending): |
519 | - # cleanup progress signal (to be sure to not leave dbus matchers around) |
520 | + # cleanup progress signal (to be sure to not leave dbus |
521 | + # matchers around) |
522 | if self._progress_signal: |
523 | GObject.source_remove(self._progress_signal) |
524 | self._progress_signal = None |
525 | @@ -683,7 +713,8 @@ |
526 | if current: |
527 | try: |
528 | trans = client.get_transaction(current) |
529 | - self._progress_signal = trans.connect("progress-changed", self._on_progress_changed) |
530 | + self._progress_signal = trans.connect("progress-changed", |
531 | + self._on_progress_changed) |
532 | except dbus.DBusException: |
533 | pass |
534 | |
535 | @@ -693,12 +724,14 @@ |
536 | if not tid: |
537 | continue |
538 | try: |
539 | - trans = client.get_transaction(tid, error_handler=lambda x: True) |
540 | + trans = client.get_transaction(tid, |
541 | + error_handler=lambda x: True) |
542 | except dbus.DBusException: |
543 | continue |
544 | trans_progress = TransactionProgress(trans) |
545 | try: |
546 | - self.pending_transactions[trans_progress.pkgname] = trans_progress |
547 | + self.pending_transactions[trans_progress.pkgname] = \ |
548 | + trans_progress |
549 | except KeyError: |
550 | # if its not a transaction from us (sc_pkgname) still |
551 | # add it with the tid as key to get accurate results |
552 | @@ -709,19 +742,20 @@ |
553 | self.inject_fake_transactions_and_emit_changed_signal() |
554 | |
555 | def inject_fake_transactions_and_emit_changed_signal(self): |
556 | - """ |
557 | + """ |
558 | ensures that the fake transactions are considered and emits |
559 | transactions-changed signal with the right pending transactions |
560 | """ |
561 | # inject a bunch FakePurchaseTransaction into the transations dict |
562 | for pkgname in self.pending_purchases: |
563 | - self.pending_transactions[pkgname] = self.pending_purchases[pkgname] |
564 | + self.pending_transactions[pkgname] = \ |
565 | + self.pending_purchases[pkgname] |
566 | # and emit the signal |
567 | self.emit("transactions-changed", self.pending_transactions) |
568 | |
569 | def _on_progress_changed(self, trans, progress): |
570 | - """ |
571 | - internal helper that gets called on our package transaction progress |
572 | + """ |
573 | + internal helper that gets called on our package transaction progress |
574 | (only showing pkg progress currently) |
575 | """ |
576 | try: |
577 | @@ -741,7 +775,8 @@ |
578 | return |
579 | # hide any private ppa details in the error message since it may |
580 | # appear in the logs for LP bugs and potentially in screenshots as well |
581 | - cleaned_error_details = obfuscate_private_ppa_details(trans.error_details) |
582 | + cleaned_error_details = obfuscate_private_ppa_details( |
583 | + trans.error_details) |
584 | msg = utf8("%s: %s\n%s\n\n%s") % ( |
585 | utf8(_("Error")), |
586 | utf8(enums.get_error_string_from_enum(trans.error_code)), |
587 | @@ -750,20 +785,23 @@ |
588 | self._logger.error("error in _on_trans_finished '%s'" % msg) |
589 | # show dialog to the user and exit (no need to reopen the cache) |
590 | if not trans.error_code: |
591 | - # sometimes aptdaemon doesn't return a value for error_code when the network |
592 | - # connection has become unavailable; in that case, we will assume it's a |
593 | - # failure during a package download because that is the only case where we |
594 | - # see this happening - this avoids display of an empty error dialog and |
595 | - # correctly prompts the user to check their network connection (see LP: #747172) |
596 | - # FIXME: fix aptdaemon to return a valid error_code under all conditions |
597 | + # sometimes aptdaemon doesn't return a value for error_code |
598 | + # when the network connection has become unavailable; in |
599 | + # that case, we will assume it's a failure during a package |
600 | + # download because that is the only case where we see this |
601 | + # happening - this avoids display of an empty error dialog |
602 | + # and correctly prompts the user to check their network |
603 | + # connection (see LP: #747172) |
604 | + # FIXME: fix aptdaemon to return a valid error_code under |
605 | + # all conditions |
606 | trans.error_code = enums.ERROR_PACKAGE_DOWNLOAD_FAILED |
607 | # show dialog to the user and exit (no need to reopen |
608 | # the cache) |
609 | res = self.ui.error(None, |
610 | - utf8(enums.get_error_string_from_enum(trans.error_code)), |
611 | - utf8(enums.get_error_description_from_enum(trans.error_code)), |
612 | - utf8(cleaned_error_details), |
613 | - utf8(alternative_action)) |
614 | + utf8(enums.get_error_string_from_enum(trans.error_code)), |
615 | + utf8(enums.get_error_description_from_enum(trans.error_code)), |
616 | + utf8(cleaned_error_details), |
617 | + utf8(alternative_action)) |
618 | return res |
619 | |
620 | def _get_app_and_icon_and_deb_from_trans(self, trans): |
621 | @@ -794,7 +832,7 @@ |
622 | self.install(app, iconname, filename, [], [], |
623 | metadata=meta_copy, force=True) |
624 | return |
625 | - # on unauthenticated errors, try a "repair" using the |
626 | + # on unauthenticated errors, try a "repair" using the |
627 | # reload functionatlity |
628 | elif trans.error.code == enums.ERROR_PACKAGE_UNAUTHENTICATED: |
629 | action = _("Repair") |
630 | @@ -808,7 +846,8 @@ |
631 | metadata=meta_copy) |
632 | return |
633 | |
634 | - elif not "sc_add_repo_and_install_ignore_errors" in trans.meta_data: |
635 | + elif (not "sc_add_repo_and_install_ignore_errors" in |
636 | + trans.meta_data): |
637 | self._show_transaction_failed_dialog(trans, enum) |
638 | |
639 | # send finished signal, use "" here instead of None, because |
640 | @@ -827,7 +866,8 @@ |
641 | self.emit("reload-finished", trans, enum != enums.EXIT_FAILED) |
642 | # send appropriate signals |
643 | self.inject_fake_transactions_and_emit_changed_signal() |
644 | - self.emit("transaction-finished", TransactionFinishedResult(trans, enum != enums.EXIT_FAILED)) |
645 | + self.emit("transaction-finished", TransactionFinishedResult(trans, |
646 | + enum != enums.EXIT_FAILED)) |
647 | |
648 | @inline_callbacks |
649 | def _config_file_conflict(self, transaction, old, new): |
650 | @@ -871,7 +911,8 @@ |
651 | # setup debconf only if we have a pkg |
652 | yield trans.set_debconf_frontend("gnome", defer=True) |
653 | trans.set_remove_obsoleted_depends(True, defer=True) |
654 | - self._progress_signal = trans.connect("progress-changed", self._on_progress_changed) |
655 | + self._progress_signal = trans.connect("progress-changed", |
656 | + self._on_progress_changed) |
657 | self.pending_transactions[pkgname] = TransactionProgress(trans) |
658 | # generic metadata |
659 | if metadata: |
660 | @@ -919,4 +960,3 @@ |
661 | backend.enable_component("multiverse") |
662 | from gi.repository import Gtk |
663 | Gtk.main() |
664 | - |
665 | |
666 | === modified file 'softwarecenter/backend/installbackend_impl/packagekit_enums.py' |
667 | --- softwarecenter/backend/installbackend_impl/packagekit_enums.py 2011-12-16 12:50:18 +0000 |
668 | +++ softwarecenter/backend/installbackend_impl/packagekit_enums.py 2012-03-16 20:20:25 +0000 |
669 | @@ -18,9 +18,11 @@ |
670 | |
671 | from gi.repository import PackageKitGlib as packagekit |
672 | |
673 | + |
674 | # this requires packagekit 0.7.2 or better |
675 | -def status_enum_to_localised_text (status): |
676 | +def status_enum_to_localised_text(status): |
677 | return packagekit.info_enum_to_localised_present(status) |
678 | |
679 | -def role_enum_to_localised_present (role): |
680 | + |
681 | +def role_enum_to_localised_present(role): |
682 | return packagekit.role_enum_to_localised_present(role) |
683 | |
684 | === modified file 'softwarecenter/backend/installbackend_impl/packagekitd.py' |
685 | --- softwarecenter/backend/installbackend_impl/packagekitd.py 2012-02-07 16:56:40 +0000 |
686 | +++ softwarecenter/backend/installbackend_impl/packagekitd.py 2012-03-16 20:20:25 +0000 |
687 | @@ -24,10 +24,12 @@ |
688 | from gi.repository import PackageKitGlib as packagekit |
689 | |
690 | from softwarecenter.enums import TransactionTypes |
691 | -from softwarecenter.backend.transactionswatcher import (BaseTransactionsWatcher, |
692 | - BaseTransaction, |
693 | - TransactionFinishedResult, |
694 | - TransactionProgress) |
695 | +from softwarecenter.backend.transactionswatcher import ( |
696 | + BaseTransactionsWatcher, |
697 | + BaseTransaction, |
698 | + TransactionFinishedResult, |
699 | + TransactionProgress |
700 | +) |
701 | from softwarecenter.backend.installbackend import InstallBackend |
702 | from softwarecenter.backend.installbackend_impl import packagekit_enums |
703 | |
704 | @@ -36,9 +38,10 @@ |
705 | |
706 | LOG = logging.getLogger("softwarecenter.backend.packagekit") |
707 | |
708 | + |
709 | class PackagekitTransaction(BaseTransaction): |
710 | _meta_data = {} |
711 | - |
712 | + |
713 | def __init__(self, trans): |
714 | """ trans -- a PkProgress object """ |
715 | GObject.GObject.__init__(self) |
716 | @@ -50,18 +53,26 @@ |
717 | because PK DBus exposes only a generic Changed, without |
718 | specifying the property changed |
719 | """ |
720 | - self._trans.connect('notify::role', self._emit, 'role-changed', 'role') |
721 | - self._trans.connect('notify::status', self._emit, 'status-changed', 'status') |
722 | - self._trans.connect('notify::percentage', self._emit, 'progress-changed', 'percentage') |
723 | - #self._trans.connect('notify::subpercentage', self._emit, 'progress-changed', 'subpercentage') # SC UI does not support subprogress |
724 | - self._trans.connect('notify::percentage', self._emit, 'progress-changed', 'percentage') |
725 | - self._trans.connect('notify::allow-cancel', self._emit, 'cancellable-changed', 'allow-cancel') |
726 | + self._trans.connect('notify::role', self._emit, |
727 | + 'role-changed', 'role') |
728 | + self._trans.connect('notify::status', self._emit, |
729 | + 'status-changed', 'status') |
730 | + self._trans.connect('notify::percentage', self._emit, |
731 | + 'progress-changed', 'percentage') |
732 | + # SC UI does not support subprogress: |
733 | + #self._trans.connect('notify::subpercentage', self._emit, |
734 | + # 'progress-changed', 'subpercentage') |
735 | + self._trans.connect('notify::percentage', self._emit, |
736 | + 'progress-changed', 'percentage') |
737 | + self._trans.connect('notify::allow-cancel', self._emit, |
738 | + 'cancellable-changed', 'allow-cancel') |
739 | |
740 | # connect the delete: |
741 | - proxy = dbus.SystemBus().get_object('org.freedesktop.PackageKit', self.tid) |
742 | + proxy = dbus.SystemBus().get_object('org.freedesktop.PackageKit', |
743 | + self.tid) |
744 | trans = dbus.Interface(proxy, 'org.freedesktop.PackageKit.Transaction') |
745 | trans.connect_to_signal("Destroy", self._remove) |
746 | - |
747 | + |
748 | def _emit(self, *args): |
749 | prop, what = args[-1], args[-2] |
750 | self.emit(what, self._trans.get_property(prop)) |
751 | @@ -69,25 +80,31 @@ |
752 | @property |
753 | def tid(self): |
754 | return self._trans.get_property('transaction-id') |
755 | + |
756 | @property |
757 | def status_details(self): |
758 | - return self.get_status_description() # FIXME |
759 | + return self.get_status_description() # FIXME |
760 | + |
761 | @property |
762 | def meta_data(self): |
763 | return self._meta_data |
764 | + |
765 | @property |
766 | def cancellable(self): |
767 | return self._trans.get_property('allow-cancel') |
768 | + |
769 | @property |
770 | def progress(self): |
771 | return self._trans.get_property('percentage') |
772 | |
773 | def get_role_description(self, role=None): |
774 | role = role if role is not None else self._trans.get_property('role') |
775 | - return self.meta_data.get('sc_appname', packagekit_enums.role_enum_to_localised_present(role)) |
776 | + return self.meta_data.get('sc_appname', |
777 | + packagekit_enums.role_enum_to_localised_present(role)) |
778 | |
779 | def get_status_description(self, status=None): |
780 | - status = status if status is not None else self._trans.get_property('status') |
781 | + if status is None: |
782 | + status = self._trans.get_property('status') |
783 | |
784 | return packagekit_enums.status_enum_to_localised_text(status) |
785 | |
786 | @@ -107,7 +124,8 @@ |
787 | status <= packagekit.StatusEnum.DOWNLOAD_UPDATEINFO) |
788 | |
789 | def cancel(self): |
790 | - proxy = dbus.SystemBus().get_object('org.freedesktop.PackageKit', self.tid) |
791 | + proxy = dbus.SystemBus().get_object('org.freedesktop.PackageKit', |
792 | + self.tid) |
793 | trans = dbus.Interface(proxy, 'org.freedesktop.PackageKit.Transaction') |
794 | trans.Cancel() |
795 | |
796 | @@ -120,6 +138,7 @@ |
797 | del PackagekitTransactionsWatcher._tlist[self.tid] |
798 | LOG.debug("Delete transaction %s" % self.tid) |
799 | |
800 | + |
801 | class PackagekitTransactionsWatcher(BaseTransactionsWatcher): |
802 | _tlist = {} |
803 | |
804 | @@ -128,9 +147,10 @@ |
805 | self.client = packagekit.Client() |
806 | |
807 | bus = dbus.SystemBus() |
808 | - proxy = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit') |
809 | + proxy = bus.get_object('org.freedesktop.PackageKit', |
810 | + '/org/freedesktop/PackageKit') |
811 | daemon = dbus.Interface(proxy, 'org.freedesktop.PackageKit') |
812 | - daemon.connect_to_signal("TransactionListChanged", |
813 | + daemon.connect_to_signal("TransactionListChanged", |
814 | self._on_transactions_changed) |
815 | queued = daemon.GetTransactionList() |
816 | self._on_transactions_changed(queued) |
817 | @@ -161,29 +181,30 @@ |
818 | return trans |
819 | return PackagekitTransactionsWatcher._tlist[tid] |
820 | |
821 | + |
822 | class PackagekitBackend(GObject.GObject, InstallBackend): |
823 | - |
824 | - __gsignals__ = {'transaction-started':(GObject.SIGNAL_RUN_FIRST, |
825 | + |
826 | + __gsignals__ = {'transaction-started': (GObject.SIGNAL_RUN_FIRST, |
827 | GObject.TYPE_NONE, |
828 | - (str,str,str,str)), |
829 | + (str, str, str, str)), |
830 | # emits a TransactionFinished object |
831 | - 'transaction-finished':(GObject.SIGNAL_RUN_FIRST, |
832 | - GObject.TYPE_NONE, |
833 | - (GObject.TYPE_PYOBJECT, )), |
834 | - 'transaction-stopped':(GObject.SIGNAL_RUN_FIRST, |
835 | + 'transaction-finished': (GObject.SIGNAL_RUN_FIRST, |
836 | + GObject.TYPE_NONE, |
837 | + (GObject.TYPE_PYOBJECT, )), |
838 | + 'transaction-stopped': (GObject.SIGNAL_RUN_FIRST, |
839 | GObject.TYPE_NONE, |
840 | (GObject.TYPE_PYOBJECT,)), |
841 | - 'transactions-changed':(GObject.SIGNAL_RUN_FIRST, |
842 | - GObject.TYPE_NONE, |
843 | - (GObject.TYPE_PYOBJECT, )), |
844 | - 'transaction-progress-changed':(GObject.SIGNAL_RUN_FIRST, |
845 | - GObject.TYPE_NONE, |
846 | - (str,int,)), |
847 | + 'transactions-changed': (GObject.SIGNAL_RUN_FIRST, |
848 | + GObject.TYPE_NONE, |
849 | + (GObject.TYPE_PYOBJECT, )), |
850 | + 'transaction-progress-changed': (GObject.SIGNAL_RUN_FIRST, |
851 | + GObject.TYPE_NONE, |
852 | + (str, int,)), |
853 | # the number/names of the available channels changed |
854 | # FIXME: not emitted. |
855 | - 'channels-changed':(GObject.SIGNAL_RUN_FIRST, |
856 | - GObject.TYPE_NONE, |
857 | - (bool,)), |
858 | + 'channels-changed': (GObject.SIGNAL_RUN_FIRST, |
859 | + GObject.TYPE_NONE, |
860 | + (bool,)), |
861 | } |
862 | |
863 | def __init__(self): |
864 | @@ -192,7 +213,7 @@ |
865 | |
866 | # transaction details for setting as meta |
867 | self.new_pkgname, self.new_appname, self.new_iconname = '', '', '' |
868 | - |
869 | + |
870 | # this is public exposed |
871 | self.pending_transactions = {} |
872 | |
873 | @@ -202,11 +223,12 @@ |
874 | |
875 | self._transactions_watcher = PackagekitTransactionsWatcher() |
876 | self._transactions_watcher.connect('lowlevel-transactions-changed', |
877 | - self._on_lowlevel_transactions_changed) |
878 | + self._on_lowlevel_transactions_changed) |
879 | |
880 | def upgrade(self, pkgname, appname, iconname, addons_install=[], |
881 | addons_remove=[], metadata=None): |
882 | - pass # FIXME implement it |
883 | + pass # FIXME implement it |
884 | + |
885 | def remove(self, app, iconname, addons_install=[], |
886 | addons_remove=[], metadata=None): |
887 | self.remove_multiple((app,), (iconname,), |
888 | @@ -220,26 +242,29 @@ |
889 | appnames = [app.appname for app in apps] |
890 | |
891 | # keep track of pkg, app and icon for setting them as meta |
892 | - self.new_pkgname, self.new_appname, self.new_iconname = pkgnames[0], appnames[0], iconnames[0] |
893 | + self.new_pkgname = pkgnames[0] |
894 | + self.new_appname = appnames[0] |
895 | + self.new_iconname = iconnames[0] |
896 | |
897 | # temporary hack |
898 | pkgnames = self._fix_pkgnames(pkgnames) |
899 | |
900 | self.client.remove_packages_async(pkgnames, |
901 | - False, # allow deps |
902 | - False, # autoremove |
903 | - None, # cancellable |
904 | + False, # allow deps |
905 | + False, # autoremove |
906 | + None, # cancellable |
907 | self._on_progress_changed, |
908 | - None, # progress data |
909 | - self._on_remove_ready, # callback ready |
910 | - None # callback data |
911 | + None, # progress data |
912 | + self._on_remove_ready, # callback ready |
913 | + None # callback data |
914 | ) |
915 | - self.emit("transaction-started", pkgnames[0], appnames[0], 0, TransactionTypes.REMOVE) |
916 | + self.emit("transaction-started", pkgnames[0], appnames[0], 0, |
917 | + TransactionTypes.REMOVE) |
918 | |
919 | def install(self, app, iconname, filename=None, |
920 | addons_install=[], addons_remove=[], metadata=None): |
921 | if filename is not None: |
922 | - LOG.error("Filename not implemented") # FIXME |
923 | + LOG.error("Filename not implemented") # FIXME |
924 | else: |
925 | self.install_multiple((app,), (iconname,), |
926 | addons_install, addons_remove, metadata |
927 | @@ -252,7 +277,9 @@ |
928 | appnames = [app.appname for app in apps] |
929 | |
930 | # keep track of pkg, app and icon for setting them as meta |
931 | - self.new_pkgname, self.new_appname, self.new_iconname = pkgnames[0], appnames[0], iconnames[0] |
932 | + self.new_pkgname = pkgnames[0] |
933 | + self.new_appname = appnames[0] |
934 | + self.new_iconname = iconnames[0] |
935 | |
936 | # temporary hack |
937 | pkgnames = self._fix_pkgnames(pkgnames) |
938 | @@ -263,19 +290,21 @@ |
939 | # PackageKit from installing untrusted packages |
940 | # (in general, all enabled repos should have GPG signatures, |
941 | # which is enough for being marked "trusted", but still) |
942 | - self.client.install_packages_async(True, # only trusted |
943 | + self.client.install_packages_async(True, # only trusted |
944 | pkgnames, |
945 | - None, # cancellable |
946 | + None, # cancellable |
947 | self._on_progress_changed, |
948 | - None, # progress data |
949 | - self._on_install_ready, # GAsyncReadyCallback |
950 | + None, # progress data |
951 | + self._on_install_ready, # GAsyncReadyCallback |
952 | None # ready data |
953 | ) |
954 | - self.emit("transaction-started", pkgnames[0], appnames[0], 0, TransactionTypes.INSTALL) |
955 | + self.emit("transaction-started", pkgnames[0], appnames[0], 0, |
956 | + TransactionTypes.INSTALL) |
957 | |
958 | def apply_changes(self, pkgname, appname, iconname, |
959 | addons_install=[], addons_remove=[], metadata=None): |
960 | pass |
961 | + |
962 | def reload(self, sources_list=None, metadata=None): |
963 | """ reload package list """ |
964 | pass |
965 | @@ -313,15 +342,19 @@ |
966 | if self.new_pkgname not in self.pending_transactions: |
967 | self.pending_transactions[self.new_pkgname] = trans |
968 | |
969 | - #LOG.debug("Progress update %s %s %s %s" % (status, ptype, progress.get_property('transaction-id'),progress.get_property('status'))) |
970 | + # LOG.debug("Progress update %s %s %s %s" % |
971 | + # (status, ptype, progress.get_property('transaction-id'), |
972 | + # progress.get_property('status'))) |
973 | |
974 | if status == packagekit.StatusEnum.FINISHED: |
975 | LOG.debug("Transaction finished %s" % tid) |
976 | - self.emit("transaction-finished", TransactionFinishedResult(trans, True)) |
977 | + self.emit("transaction-finished", |
978 | + TransactionFinishedResult(trans, True)) |
979 | |
980 | if status == packagekit.StatusEnum.CANCEL: |
981 | LOG.debug("Transaction canceled %s" % tid) |
982 | - self.emit("transaction-stopped", TransactionFinishedResult(trans, True)) |
983 | + self.emit("transaction-stopped", |
984 | + TransactionFinishedResult(trans, True)) |
985 | |
986 | if ptype == packagekit.ProgressType.PACKAGE: |
987 | # this should be done better |
988 | @@ -348,7 +381,8 @@ |
989 | trans = self._transactions_watcher.get_transaction(tid) |
990 | trans_progress = TransactionProgress(trans) |
991 | try: |
992 | - self.pending_transactions[trans_progress.pkgname] = trans_progress |
993 | + self.pending_transactions[ |
994 | + trans_progress.pkgname] = trans_progress |
995 | except: |
996 | self.pending_transactions[trans.tid] = trans_progress |
997 | |
998 | @@ -375,7 +409,7 @@ |
999 | |
1000 | loop = dbus.mainloop.glib.DBusGMainLoop() |
1001 | dbus.set_default_main_loop(loop) |
1002 | - |
1003 | + |
1004 | backend = PackagekitBackend() |
1005 | pkginfo = get_pkg_info() |
1006 | if pkginfo[package].is_installed: |
1007 | @@ -387,4 +421,3 @@ |
1008 | from gi.repository import Gtk |
1009 | Gtk.main() |
1010 | #print backend._fix_pkgnames(('cheese',)) |
1011 | - |
1012 | |
1013 | === modified file 'softwarecenter/backend/piston/rnrclient.py' |
1014 | --- softwarecenter/backend/piston/rnrclient.py 2011-10-26 10:25:49 +0000 |
1015 | +++ softwarecenter/backend/piston/rnrclient.py 2012-03-16 20:20:25 +0000 |
1016 | @@ -31,15 +31,18 @@ |
1017 | # get the server to use |
1018 | from softwarecenter.distro import get_distro |
1019 | distro = get_distro() |
1020 | -SERVER_ROOT=distro.REVIEWS_SERVER |
1021 | +SERVER_ROOT = distro.REVIEWS_SERVER |
1022 | |
1023 | try: |
1024 | if "SOFTWARE_CENTER_FAKE_REVIEW_API" in os.environ: |
1025 | - from softwarecenter.backend.piston.rnrclient_fake import RatingsAndReviewsAPI |
1026 | + from softwarecenter.backend.piston.rnrclient_fake import ( |
1027 | + RatingsAndReviewsAPI |
1028 | + ) |
1029 | RatingsAndReviewsAPI.default_service_root = SERVER_ROOT |
1030 | import rnrclient_fake |
1031 | rnrclient_fake |
1032 | - LOG.warn("using FAKE review api, data returned will be dummy data only") |
1033 | + LOG.warn("using FAKE review api, data returned will be dummy " |
1034 | + "data only") |
1035 | else: |
1036 | # patch default_service_root |
1037 | from rnrclient_pristine import RatingsAndReviewsAPI |
1038 | @@ -68,22 +71,24 @@ |
1039 | # dump all reviews |
1040 | for stat in rnr.review_stats(): |
1041 | print("stats for (pkg='%s', app: '%s'): avg=%s total=%s" % ( |
1042 | - stat.package_name, stat.app_name, stat.ratings_average, stat.ratings_total)) |
1043 | + stat.package_name, stat.app_name, stat.ratings_average, |
1044 | + stat.ratings_total)) |
1045 | reviews = rnr.get_reviews( |
1046 | language="any", origin="ubuntu", distroseries="natty", |
1047 | packagename=stat.package_name, |
1048 | appname=urllib.quote_plus(stat.app_name.encode("utf-8"))) |
1049 | for review in reviews: |
1050 | - print("rating: %s user=%s" % (review.rating, review.reviewer_username)) |
1051 | + print("rating: %s user=%s" % (review.rating, |
1052 | + review.reviewer_username)) |
1053 | print(review.summary) |
1054 | print(review.review_text) |
1055 | print("\n") |
1056 | - |
1057 | + |
1058 | # get individual ones |
1059 | - reviews = rnr.get_reviews(language="en",origin="ubuntu",distroseries="maverick", |
1060 | - packagename="unace", appname="ACE") |
1061 | + reviews = rnr.get_reviews(language="en", origin="ubuntu", |
1062 | + distroseries="maverick", packagename="unace", appname="ACE") |
1063 | print(reviews) |
1064 | - print(rnr.get_reviews(language="en",origin="ubuntu",distroseries="natty", |
1065 | + print(rnr.get_reviews(language="en", origin="ubuntu", distroseries="natty", |
1066 | packagename="aclock.app")) |
1067 | print(rnr.get_reviews(language="en", origin="ubuntu", distroseries="natty", |
1068 | packagename="unace", appname="ACE")) |
1069 | |
1070 | === modified file 'softwarecenter/backend/piston/rnrclient_fake.py' |
1071 | --- softwarecenter/backend/piston/rnrclient_fake.py 2011-08-15 11:55:13 +0000 |
1072 | +++ softwarecenter/backend/piston/rnrclient_fake.py 2012-03-16 20:20:25 +0000 |
1073 | @@ -17,36 +17,40 @@ |
1074 | AUTHENTICATED_API_SCHEME = 'https' |
1075 | |
1076 | from rnrclient_pristine import ReviewRequest, ReviewsStats, ReviewDetails |
1077 | -from softwarecenter.backend.fake_review_settings import FakeReviewSettings, network_delay |
1078 | +from softwarecenter.backend.fake_review_settings import ( |
1079 | + FakeReviewSettings, |
1080 | + network_delay, |
1081 | +) |
1082 | import json |
1083 | import random |
1084 | import time |
1085 | |
1086 | |
1087 | class RatingsAndReviewsAPI(PistonAPI): |
1088 | - """A fake client pretending to be RAtingsAndReviewsAPI from rnrclient_pristine. |
1089 | - Uses settings from test.fake_review_settings.FakeReviewSettings |
1090 | - to provide predictable responses to methods that try to use the |
1091 | - RatingsAndReviewsAPI for testing purposes (i.e. without network activity). |
1092 | - To use this, instead of importing from rnrclient_pristine, you can import |
1093 | - from rnrclient_fake instead. |
1094 | + """A fake client pretending to be RAtingsAndReviewsAPI from |
1095 | + rnrclient_pristine. Uses settings from |
1096 | + test.fake_review_settings.FakeReviewSettings |
1097 | + to provide predictable responses to methods that try to use the |
1098 | + RatingsAndReviewsAPI for testing purposes (i.e. without network |
1099 | + activity). |
1100 | + To use this, instead of importing from rnrclient_pristine, you can |
1101 | + import from rnrclient_fake instead. |
1102 | """ |
1103 | - |
1104 | + |
1105 | default_service_root = 'http://localhost:8000/reviews/api/1.0' |
1106 | default_content_type = 'application/x-www-form-urlencoded' |
1107 | _exception_msg = 'Fake RatingsAndReviewsAPI raising fake exception' |
1108 | - _PACKAGE_NAMES = ['armagetronad', 'compizconfig-settings-manager', 'file-roller', |
1109 | - 'aisleriot', 'p7zip-full', 'compiz-core', 'banshee', |
1110 | - 'gconf-editor', 'nanny', '3depict', 'apturl', 'jockey-gtk', |
1111 | - 'alex4', 'bzr-explorer', 'aqualung'] |
1112 | - _USERS = ["Joe Doll", "John Foo", "Cat Lala", "Foo Grumpf", |
1113 | + _PACKAGE_NAMES = ['armagetronad', 'compizconfig-settings-manager', |
1114 | + 'file-roller', 'aisleriot', 'p7zip-full', 'compiz-core', |
1115 | + 'banshee', 'gconf-editor', 'nanny', '3depict', 'apturl', |
1116 | + 'jockey-gtk', 'alex4', 'bzr-explorer', 'aqualung'] |
1117 | + _USERS = ["Joe Doll", "John Foo", "Cat Lala", "Foo Grumpf", |
1118 | "Bar Tender", "Baz Lightyear"] |
1119 | _SUMMARIES = ["Cool", "Medium", "Bad", "Too difficult"] |
1120 | - _TEXT = ["Review text number 1", "Review text number 2", |
1121 | + _TEXT = ["Review text number 1", "Review text number 2", |
1122 | "Review text number 3", "Review text number 4"] |
1123 | _fake_settings = FakeReviewSettings() |
1124 | |
1125 | - |
1126 | @returns_json |
1127 | @network_delay |
1128 | def server_status(self): |
1129 | @@ -54,32 +58,31 @@ |
1130 | raise APIError(self._exception_msg) |
1131 | return json.dumps('ok') |
1132 | |
1133 | - |
1134 | @validate_pattern('origin', r'[0-9a-z+-.:/]+', required=False) |
1135 | @validate_pattern('distroseries', r'\w+', required=False) |
1136 | @validate('days', int, required=False) |
1137 | @returns_list_of(ReviewsStats) |
1138 | @network_delay |
1139 | def review_stats(self, origin='any', distroseries='any', days=None, |
1140 | - valid_days=(1,3,7)): |
1141 | + valid_days=(1, 3, 7)): |
1142 | if self._fake_settings.get_setting('review_stats_error'): |
1143 | raise APIError(self._exception_msg) |
1144 | - |
1145 | + |
1146 | if self._fake_settings.get_setting('packages_returned') > 15: |
1147 | quantity = 15 |
1148 | else: |
1149 | quantity = self._fake_settings.get_setting('packages_returned') |
1150 | - |
1151 | + |
1152 | stats = [] |
1153 | - |
1154 | - for i in range (0, quantity): |
1155 | - s = {'app_name':'', |
1156 | - 'package_name':self._PACKAGE_NAMES[i], |
1157 | - 'ratings_total': str(random.randrange(1,200)), |
1158 | - 'ratings_average': str(random.randrange(0,5)) |
1159 | + |
1160 | + for i in range(0, quantity): |
1161 | + s = {'app_name': '', |
1162 | + 'package_name': self._PACKAGE_NAMES[i], |
1163 | + 'ratings_total': str(random.randrange(1, 200)), |
1164 | + 'ratings_average': str(random.randrange(0, 5)) |
1165 | } |
1166 | stats.append(s) |
1167 | - |
1168 | + |
1169 | return json.dumps(stats) |
1170 | |
1171 | @validate_pattern('language', r'\w+', required=False) |
1172 | @@ -94,7 +97,7 @@ |
1173 | @network_delay |
1174 | def get_reviews(self, packagename, language='any', origin='any', |
1175 | distroseries='any', version='any', appname='', page=1, sort='helpful'): |
1176 | - |
1177 | + |
1178 | # work out how many reviews to return for pagination |
1179 | if page <= self._fake_settings.get_setting('review_pages'): |
1180 | num_reviews = 10 |
1181 | @@ -102,10 +105,10 @@ |
1182 | num_reviews = self._fake_settings.get_setting('reviews_returned') |
1183 | else: |
1184 | num_reviews = 0 |
1185 | - |
1186 | + |
1187 | if self._fake_settings.get_setting('get_reviews_error'): |
1188 | raise APIError(self._exception_msg) |
1189 | - |
1190 | + |
1191 | reviews = self._make_fake_reviews(packagename, num_reviews) |
1192 | return json.dumps(reviews) |
1193 | |
1194 | @@ -124,9 +127,11 @@ |
1195 | def submit_review(self, review): |
1196 | if self._fake_settings.get_setting('submit_review_error'): |
1197 | raise APIError(self._exception_msg) |
1198 | - |
1199 | - user = self._fake_settings.get_setting('reviewer_username') or random.choice(self._USERS) |
1200 | - review_id = self._fake_settings.get_setting('submit_review_id') or random.randint(1,10000) |
1201 | + |
1202 | + user = self._fake_settings.get_setting( |
1203 | + 'reviewer_username') or random.choice(self._USERS) |
1204 | + review_id = self._fake_settings.get_setting( |
1205 | + 'submit_review_id') or random.randint(1, 10000) |
1206 | r = { |
1207 | "origin": review.origin, |
1208 | "rating": review.rating, |
1209 | @@ -156,13 +161,15 @@ |
1210 | def flag_review(self, review_id, reason, text): |
1211 | if self._fake_settings.get_setting('flag_review_error'): |
1212 | raise APIError(self._exception_msg) |
1213 | - |
1214 | - mod_id = random.randint(1,500) |
1215 | - pkg = self._fake_settings.get_setting('flag_package_name') or random.choice(self._PACKAGE_NAMES) |
1216 | - username = self._fake_settings.get_setting('flagger_username') or random.choice(self._USERS) |
1217 | + |
1218 | + mod_id = random.randint(1, 500) |
1219 | + pkg = self._fake_settings.get_setting( |
1220 | + 'flag_package_name') or random.choice(self._PACKAGE_NAMES) |
1221 | + username = self._fake_settings.get_setting( |
1222 | + 'flagger_username') or random.choice(self._USERS) |
1223 | |
1224 | f = { |
1225 | - "user_id": random.randint(1,500), |
1226 | + "user_id": random.randint(1, 500), |
1227 | "description": text, |
1228 | "review_moderation_id": mod_id, |
1229 | "_user_cache": self._make_user_cache(username), |
1230 | @@ -170,7 +177,7 @@ |
1231 | "_review_moderation_cache": { |
1232 | "status": 0, |
1233 | "review_id": review_id, |
1234 | - "_review_cache": self._make_fake_reviews(packagename=pkg, |
1235 | + "_review_cache": self._make_fake_reviews(packagename=pkg, |
1236 | single_id=review_id), |
1237 | "moderation_text": text, |
1238 | "date_moderated": None, |
1239 | @@ -191,7 +198,8 @@ |
1240 | def submit_usefulness(self, review_id, useful): |
1241 | if self._fake_settings.get_setting('submit_usefulness_error'): |
1242 | raise APIError(self._exception_msg) |
1243 | - return json.dumps(self._fake_settings.get_setting('usefulness_response_string')) |
1244 | + return json.dumps(self._fake_settings.get_setting( |
1245 | + 'usefulness_response_string')) |
1246 | |
1247 | @validate('review_id', int, required=False) |
1248 | @validate_pattern('username', r'[^\n]+', required=False) |
1249 | @@ -200,24 +208,24 @@ |
1250 | def get_usefulness(self, review_id=None, username=None): |
1251 | if not username and not review_id: |
1252 | return None |
1253 | - |
1254 | + |
1255 | if self._fake_settings.get_setting('get_usefulness_error'): |
1256 | raise APIError(self._exception_msg) |
1257 | - |
1258 | + |
1259 | #just return a single fake item if the review_id was supplied |
1260 | if review_id: |
1261 | if username: |
1262 | response_user = username |
1263 | else: |
1264 | response_user = random.choice(self._USERS) |
1265 | - |
1266 | + |
1267 | response = { |
1268 | - 'username':response_user, |
1269 | - 'useful':random.choice(['True','False']), |
1270 | - 'review_id':review_id |
1271 | + 'username': response_user, |
1272 | + 'useful': random.choice(['True', 'False']), |
1273 | + 'review_id': review_id |
1274 | } |
1275 | return json.dumps([response]) |
1276 | - |
1277 | + |
1278 | #set up review ids to honour requested and also add randoms |
1279 | quantity = self._fake_settings.get_setting('votes_returned') |
1280 | id_list = self._fake_settings.get_setting('required_review_ids') |
1281 | @@ -228,23 +236,23 @@ |
1282 | rand_id_start = 0 |
1283 | else: |
1284 | rand_id_start = max(id_list) |
1285 | - |
1286 | + |
1287 | votes = [] |
1288 | - |
1289 | + |
1290 | for i in range(0, quantity): |
1291 | #assign review ids requested if any still exist |
1292 | try: |
1293 | id = id_list[i] |
1294 | except IndexError: |
1295 | - id = random.randint(rand_id_start,10000) |
1296 | - |
1297 | + id = random.randint(rand_id_start, 10000) |
1298 | + |
1299 | u = { |
1300 | - 'username': username, |
1301 | - 'useful': random.choice(['True','False']), |
1302 | - 'review_id' : id |
1303 | + 'username': username, |
1304 | + 'useful': random.choice(['True', 'False']), |
1305 | + 'review_id': id |
1306 | } |
1307 | votes.append(u) |
1308 | - |
1309 | + |
1310 | return json.dumps(votes) |
1311 | |
1312 | @validate('review_id', int) |
1313 | @@ -261,29 +269,28 @@ |
1314 | def modify_review(self, review_id, rating, summary, review_text): |
1315 | """Modify an existing review""" |
1316 | return json.dumps(self._make_fake_reviews()[0]) |
1317 | - |
1318 | - |
1319 | - def _make_fake_reviews(self, packagename='compiz-core', |
1320 | + |
1321 | + def _make_fake_reviews(self, packagename='compiz-core', |
1322 | quantity=1, single_id=None): |
1323 | """Make and return a requested quantity of fake reviews""" |
1324 | - |
1325 | + |
1326 | reviews = [] |
1327 | - |
1328 | + |
1329 | for i in range(0, quantity): |
1330 | if quantity == 1 and single_id: |
1331 | id = single_id |
1332 | else: |
1333 | - id = i*3 |
1334 | - |
1335 | + id = i * 3 |
1336 | + |
1337 | r = { |
1338 | "origin": "ubuntu", |
1339 | - "rating": random.randint(1,5), |
1340 | + "rating": random.randint(1, 5), |
1341 | "hide": False, |
1342 | "app_name": "", |
1343 | "language": "en", |
1344 | "reviewer_username": random.choice(self._USERS), |
1345 | - "usefulness_total": random.randint(3,6), |
1346 | - "usefulness_favorable": random.randint(1,3), |
1347 | + "usefulness_total": random.randint(3, 6), |
1348 | + "usefulness_favorable": random.randint(1, 3), |
1349 | "review_text": random.choice(self._TEXT), |
1350 | "date_deleted": None, |
1351 | "summary": random.choice(self._SUMMARIES), |
1352 | @@ -295,13 +302,13 @@ |
1353 | "distroseries": "natty" |
1354 | } |
1355 | reviews.append(r) |
1356 | - |
1357 | + |
1358 | #get_review wants a dict but get_reviews wants a list of dicts |
1359 | if single_id: |
1360 | return r |
1361 | else: |
1362 | return reviews |
1363 | - |
1364 | + |
1365 | def _make_user_cache(self, username): |
1366 | return { |
1367 | "username": username, |
1368 | @@ -313,7 +320,6 @@ |
1369 | "is_staff": False, |
1370 | "last_login": time.strftime("%Y-%m-%d %H:%M:%S"), |
1371 | "password": "!", |
1372 | - "id": random.randint(1,500), |
1373 | + "id": random.randint(1, 500), |
1374 | "date_joined": time.strftime("%Y-%m-%d %H:%M:%S") |
1375 | } |
1376 | - |
1377 | |
1378 | === modified file 'softwarecenter/backend/piston/rnrclient_pristine.py' |
1379 | --- softwarecenter/backend/piston/rnrclient_pristine.py 2011-08-15 11:55:13 +0000 |
1380 | +++ softwarecenter/backend/piston/rnrclient_pristine.py 2012-03-16 20:20:25 +0000 |
1381 | @@ -29,6 +29,7 @@ |
1382 | 'rating', 'language', 'origin', 'distroseries', 'arch_tag') |
1383 | app_name = '' |
1384 | |
1385 | + |
1386 | class ReviewsStats(PistonResponseObject): |
1387 | """A ratings summary for a package/app. |
1388 | |
1389 | @@ -82,7 +83,7 @@ |
1390 | @validate('days', int, required=False) |
1391 | @returns_list_of(ReviewsStats) |
1392 | def review_stats(self, origin='any', distroseries='any', days=None, |
1393 | - valid_days=(1,3,7)): |
1394 | + valid_days=(1, 3, 7)): |
1395 | """Fetch ratings for a particular distroseries""" |
1396 | url = 'review-stats/{0}/{1}/'.format(origin, distroseries) |
1397 | if days is not None: |
1398 | @@ -115,7 +116,7 @@ |
1399 | appname = quote_plus(';' + appname) |
1400 | return self._get('reviews/filter/%s/%s/%s/%s/%s%s/page/%s/%s/' % ( |
1401 | language, origin, distroseries, version, packagename, |
1402 | - appname, page, sort), |
1403 | + appname, page, sort), |
1404 | scheme=PUBLIC_API_SCHEME) |
1405 | |
1406 | @validate('review_id', int) |
1407 | @@ -183,6 +184,10 @@ |
1408 | @returns(ReviewDetails) |
1409 | def modify_review(self, review_id, rating, summary, review_text): |
1410 | """Modify an existing review""" |
1411 | - data = {'rating':rating, 'summary':summary, 'review_text':review_text} |
1412 | + data = { |
1413 | + 'rating': rating, |
1414 | + 'summary': summary, |
1415 | + 'review_text': review_text |
1416 | + } |
1417 | return self._put('/reviews/modify/%s/' % review_id, data=data, |
1418 | scheme=AUTHENTICATED_API_SCHEME) |
1419 | |
1420 | === modified file 'softwarecenter/backend/piston/scaclient.py' |
1421 | --- softwarecenter/backend/piston/scaclient.py 2012-01-03 16:48:01 +0000 |
1422 | +++ softwarecenter/backend/piston/scaclient.py 2012-03-16 20:20:25 +0000 |
1423 | @@ -14,7 +14,7 @@ |
1424 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1425 | # |
1426 | # |
1427 | -# taken from lp:~canonical-ca-hackers/software-center/scaclient |
1428 | +# taken from lp:~canonical-ca-hackers/software-center/scaclient |
1429 | # and put into scaclient_pristine.py |
1430 | |
1431 | import logging |
1432 | @@ -31,26 +31,27 @@ |
1433 | from softwarecenter.enums import BUY_SOMETHING_HOST |
1434 | try: |
1435 | from scaclient_pristine import SoftwareCenterAgentAPI |
1436 | - SoftwareCenterAgentAPI.default_service_root = BUY_SOMETHING_HOST+"/api/2.0" |
1437 | + SoftwareCenterAgentAPI.default_service_root = \ |
1438 | + BUY_SOMETHING_HOST + "/api/2.0" |
1439 | except: |
1440 | logging.exception("need python-piston-mini client") |
1441 | sys.exit(1) |
1442 | |
1443 | |
1444 | - |
1445 | if __name__ == "__main__": |
1446 | |
1447 | sca = SoftwareCenterAgentAPI() |
1448 | - |
1449 | + |
1450 | lang = "en" |
1451 | series = "natty" |
1452 | arch = "i386" |
1453 | |
1454 | available = sca.available_apps(lang=lang, series=series, arch=arch) |
1455 | print(available) |
1456 | - |
1457 | - available_for_qa = sca.available_apps_qa(lang=lang, series=series, arch=arch) |
1458 | + |
1459 | + available_for_qa = sca.available_apps_qa(lang=lang, series=series, |
1460 | + arch=arch) |
1461 | print(available_for_qa) |
1462 | - |
1463 | + |
1464 | for_me = sca.subscriptions_for_me() |
1465 | print(for_me) |
1466 | |
1467 | === modified file 'softwarecenter/backend/piston/scaclient_pristine.py' |
1468 | --- softwarecenter/backend/piston/scaclient_pristine.py 2012-01-03 16:03:59 +0000 |
1469 | +++ softwarecenter/backend/piston/scaclient_pristine.py 2012-03-16 20:20:25 +0000 |
1470 | @@ -8,6 +8,7 @@ |
1471 | PUBLIC_API_SCHEME = 'http' |
1472 | AUTHENTICATED_API_SCHEME = 'https' |
1473 | |
1474 | + |
1475 | class SoftwareCenterAgentAPI(PistonAPI): |
1476 | default_service_root = 'http://localhost:8000/api/2.0' |
1477 | |
1478 | |
1479 | === modified file 'softwarecenter/backend/piston/sreclient_pristine.py' |
1480 | --- softwarecenter/backend/piston/sreclient_pristine.py 2012-02-29 20:56:24 +0000 |
1481 | +++ softwarecenter/backend/piston/sreclient_pristine.py 2012-03-16 20:20:25 +0000 |
1482 | @@ -11,6 +11,7 @@ |
1483 | PUBLIC_API_SCHEME = 'http' |
1484 | AUTHENTICATED_API_SCHEME = 'https' |
1485 | |
1486 | + |
1487 | class SoftwareCenterRecommenderAPI(PistonAPI): |
1488 | default_service_root = 'http://localhost:8000/api/1.0' |
1489 | |
1490 | |
1491 | === modified file 'softwarecenter/backend/piston/sso_helper.py' |
1492 | --- softwarecenter/backend/piston/sso_helper.py 2012-01-13 16:40:48 +0000 |
1493 | +++ softwarecenter/backend/piston/sso_helper.py 2012-03-16 20:20:25 +0000 |
1494 | @@ -28,13 +28,12 @@ |
1495 | from softwarecenter.utils import clear_token_from_ubuntu_sso |
1496 | |
1497 | |
1498 | - |
1499 | class SSOLoginHelper(object): |
1500 | def __init__(self, xid=0): |
1501 | self.oauth = None |
1502 | self.xid = xid |
1503 | self.loop = GObject.MainLoop(GObject.main_context_default()) |
1504 | - |
1505 | + |
1506 | def _login_successful(self, sso_backend, oauth_result): |
1507 | self.oauth = oauth_result |
1508 | # FIXME: actually verify the token against ubuntu SSO |
1509 | @@ -44,6 +43,7 @@ |
1510 | def _whoami_done(sso, me): |
1511 | self._whoami = me |
1512 | self.loop.quit() |
1513 | + |
1514 | def _whoami_error(sso, err): |
1515 | #print "ERRR", err |
1516 | self.loop.quit() |
1517 | @@ -74,7 +74,7 @@ |
1518 | def get_oauth_token_sync(self): |
1519 | self.oauth = None |
1520 | sso = get_sso_backend( |
1521 | - self.xid, |
1522 | + self.xid, |
1523 | SOFTWARE_CENTER_NAME_KEYRING, |
1524 | _(SOFTWARE_CENTER_SSO_DESCRIPTION)) |
1525 | sso.connect("login-successful", self._login_successful) |
1526 | |
1527 | === modified file 'test/test_pep8.py' |
1528 | --- test/test_pep8.py 2012-03-16 19:16:21 +0000 |
1529 | +++ test/test_pep8.py 2012-03-16 20:20:25 +0000 |
1530 | @@ -9,6 +9,8 @@ |
1531 | # Only test these two packages for now: |
1532 | import softwarecenter.backend.reviews |
1533 | import softwarecenter.backend.oneconfhandler |
1534 | +import softwarecenter.backend.piston |
1535 | +import softwarecenter.backend.installbackend_impl |
1536 | import softwarecenter.db |
1537 | import softwarecenter.ui |
1538 | import softwarecenter.distro |
1539 | @@ -16,6 +18,8 @@ |
1540 | class PackagePep8TestCase(unittest.TestCase): |
1541 | maxDiff = None |
1542 | packages = [softwarecenter.ui, |
1543 | + softwarecenter.backend.piston, |
1544 | + softwarecenter.backend.installbackend_impl, |
1545 | softwarecenter.backend.reviews, |
1546 | softwarecenter.backend.oneconfhandler, |
1547 | softwarecenter.db, |