Merge lp:~elachuni/software-center/pep8-test-part22 into lp:software-center

Proposed by Anthony Lenton
Status: Merged
Merged at revision: 2879
Proposed branch: lp:~elachuni/software-center/pep8-test-part22
Merge into: lp:software-center
Prerequisite: lp:~elachuni/software-center/pep8-test-part21
Diff against target: 1439 lines (+352/-291)
12 files modified
softwarecenter/backend/channel.py (+74/-54)
softwarecenter/backend/fake_review_settings.py (+68/-64)
softwarecenter/backend/installbackend.py (+36/-19)
softwarecenter/backend/launchpad.py (+24/-13)
softwarecenter/backend/login.py (+16/-14)
softwarecenter/backend/login_sso.py (+29/-22)
softwarecenter/backend/recagent.py (+67/-66)
softwarecenter/backend/scagent.py (+27/-21)
softwarecenter/hw.py (+5/-2)
softwarecenter/testutils.py (+2/-3)
softwarecenter/utils.py (+1/-1)
test/test_pep8.py (+3/-12)
To merge this branch: bzr merge lp:~elachuni/software-center/pep8-test-part22
Reviewer Review Type Date Requested Status
Kiwinote Approve
Review via email: mp+98205@code.launchpad.net

Description of the change

All code under softwarecenter/ now passes the pep8 test.

To post a comment you must log in.
Revision history for this message
Kiwinote (kiwinote) wrote :

awesomeness :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/backend/channel.py'
2--- softwarecenter/backend/channel.py 2011-12-02 14:33:49 +0000
3+++ softwarecenter/backend/channel.py 2012-03-19 14:27:20 +0000
4@@ -24,13 +24,14 @@
5
6 from softwarecenter.distro import get_distro
7
8-from softwarecenter.enums import (SortMethods,
9+from softwarecenter.enums import (SortMethods,
10 Icons,
11 ViewPages,
12 )
13
14 LOG = logging.getLogger(__name__)
15
16+
17 class ChannelsManager(object):
18 def __init__(self, db, **kwargs):
19 self.distro = get_distro()
20@@ -52,10 +53,11 @@
21 # private
22 def _get_channels_from_db(self, installed_only=False):
23 """
24- (internal) implements 'channels()' and 'channels_installed_only()' properties
25+ (internal) implements 'channels()' and 'channels_installed_only()'
26+ properties
27 """
28 distro_channel_origin = self.distro.get_distro_channel_name()
29-
30+
31 # gather the set of software channels and order them
32 other_channel_list = []
33 cached_origins = []
34@@ -64,12 +66,13 @@
35 continue
36 channel_name = channel_iter.term[3:]
37 channel_origin = ""
38-
39+
40 # get origin information for this channel
41 m = self.db.xapiandb.postlist_begin(channel_iter.term)
42 doc = self.db.xapiandb.get_document(m.get_docid())
43 for term_iter in doc.termlist():
44- if term_iter.term.startswith("XOO") and len(term_iter.term) > 3:
45+ if (term_iter.term.startswith("XOO") and
46+ len(term_iter.term) > 3):
47 channel_origin = term_iter.term[3:]
48 break
49 LOG.debug("channel_name: %s" % channel_name)
50@@ -77,7 +80,7 @@
51 if channel_origin not in cached_origins:
52 other_channel_list.append((channel_name, channel_origin))
53 cached_origins.append(channel_origin)
54-
55+
56 dist_channel = None
57 other_channels = []
58 unknown_channel = []
59@@ -85,26 +88,30 @@
60
61 for (channel_name, channel_origin) in other_channel_list:
62 if not channel_name:
63- unknown_channel.append(SoftwareChannel(channel_name,
64- channel_origin,
65- None,
66- installed_only=installed_only))
67+ unknown_channel.append(SoftwareChannel(
68+ channel_name,
69+ channel_origin,
70+ None,
71+ installed_only=installed_only))
72 elif channel_origin == distro_channel_origin:
73- dist_channel = (SoftwareChannel(channel_name,
74- channel_origin,
75- None,
76- installed_only=installed_only))
77+ dist_channel = (SoftwareChannel(
78+ channel_name,
79+ channel_origin,
80+ None,
81+ installed_only=installed_only))
82 elif channel_name == "notdownloadable":
83 if installed_only:
84- local_channel = SoftwareChannel(channel_name,
85- None,
86- None,
87- installed_only=installed_only)
88+ local_channel = SoftwareChannel(
89+ channel_name,
90+ None,
91+ None,
92+ installed_only=installed_only)
93 else:
94- other_channels.append(SoftwareChannel(channel_name,
95- channel_origin,
96- None,
97- installed_only=installed_only))
98+ other_channels.append(SoftwareChannel(
99+ channel_name,
100+ channel_origin,
101+ None,
102+ installed_only=installed_only))
103
104 # set them in order
105 channels = []
106@@ -122,13 +129,14 @@
107 channel._channel_view_id = ViewPages.AVAILABLE
108 return channels
109
110+
111 class SoftwareChannel(object):
112 """
113 class to represent a software channel
114 """
115-
116+
117 ICON_SIZE = 24
118-
119+
120 def __init__(self, channel_name, channel_origin, channel_component,
121 source_entry=None, installed_only=False,
122 channel_icon=None, channel_query=None,
123@@ -148,13 +156,16 @@
124 # distro specific stuff
125 self.distro = get_distro()
126 # configure the channel
127- self._channel_display_name = self._get_display_name_for_channel(channel_name, channel_origin, channel_component)
128+ self._channel_display_name = self._get_display_name_for_channel(
129+ channel_name, channel_origin, channel_component)
130 if channel_icon is None:
131- self._channel_icon = self._get_icon_for_channel(channel_name, channel_origin, channel_component)
132+ self._channel_icon = self._get_icon_for_channel(
133+ channel_name, channel_origin, channel_component)
134 else:
135 self._channel_icon = channel_icon
136 if channel_query is None:
137- self._channel_query = self._get_channel_query_for_channel(channel_name, channel_origin, channel_component)
138+ self._channel_query = self._get_channel_query_for_channel(
139+ channel_name, channel_origin, channel_component)
140 else:
141 self._channel_query = channel_query
142 # a sources.list entry attached to the channel (this is currently
143@@ -162,36 +173,36 @@
144 self._source_entry = source_entry
145 # when the channel needs to be added to the systems sources.list
146 self.needs_adding = False
147-
148+
149 @property
150 def name(self):
151 """
152 return the channel name as represented in the xapian database
153 """
154 return self._channel_name
155-
156- @property
157+
158+ @property
159 def origin(self):
160 """
161 return the channel origin as represented in the xapian database
162 """
163 return self._channel_origin
164-
165- @property
166+
167+ @property
168 def component(self):
169 """
170 return the channel component as represented in the xapian database
171 """
172 return self._channel_component
173-
174- @property
175+
176+ @property
177 def display_name(self):
178 """
179 return the display name for the corresponding channel for use in the UI
180 """
181 return self._channel_display_name
182-
183- @property
184+
185+ @property
186 def icon(self):
187 """
188 return the icon that corresponds to each channel based
189@@ -205,18 +216,19 @@
190 return the xapian query to be used with this software channel
191 """
192 return self._channel_query
193-
194- @property
195+
196+ @property
197 def sort_mode(self):
198 """
199 return the sort mode for this software channel
200 """
201 return self._channel_sort_mode
202-
203+
204 # TODO: implement __cmp__ so that sort for channels is encapsulated
205 # here as well
206
207- def _get_display_name_for_channel(self, channel_name, channel_origin, channel_component):
208+ def _get_display_name_for_channel(self, channel_name, channel_origin,
209+ channel_component):
210 if channel_component == "partner":
211 channel_display_name = _("Canonical Partners")
212 elif not channel_origin:
213@@ -232,8 +244,9 @@
214 else:
215 return channel_name
216 return channel_display_name
217-
218- def _get_icon_for_channel(self, channel_name, channel_origin, channel_component):
219+
220+ def _get_icon_for_channel(self, channel_name, channel_origin,
221+ channel_component):
222 if channel_component == "partner":
223 channel_icon = "partner"
224 elif not channel_name:
225@@ -253,16 +266,17 @@
226 else:
227 channel_icon = "unknown-channel"
228 return channel_icon
229-
230- def _get_channel_query_for_channel(self, channel_name, channel_origin, channel_component):
231-
232+
233+ def _get_channel_query_for_channel(self, channel_name, channel_origin,
234+ channel_component):
235+
236 if channel_component == "partner":
237 q1 = xapian.Query("XOCpartner")
238 q2 = xapian.Query("AH%s-partner" % self.distro.get_codename())
239 channel_query = xapian.Query(xapian.Query.OP_OR, q1, q2)
240 # show only apps when displaying the new apps archive
241 elif channel_name == "Application Review Board PPA":
242- channel_query = xapian.Query(xapian.Query.OP_AND,
243+ channel_query = xapian.Query(xapian.Query.OP_AND,
244 xapian.Query("XOL" + channel_name),
245 xapian.Query("ATapplication"))
246 elif channel_origin:
247@@ -292,14 +306,14 @@
248 self, channel_name, "all", None,
249 installed_only=installed_only,
250 channel_icon=Icons.FALLBACK)
251- return
252
253 # overrides
254- def _get_display_name_for_channel(self, channel_name, channel_origin, channel_component):
255+ def _get_display_name_for_channel(self, channel_name, channel_origin,
256+ channel_component):
257 return channel_name
258
259 def _get_channel_query_for_channel(self, *args):
260- return None
261+ pass
262
263
264 class AllAvailableChannel(AllChannel):
265@@ -313,28 +327,34 @@
266 def __init__(self):
267 AllChannel.__init__(self, _("All Installed"), True)
268
269+
270 # singleton
271 channels_manager = None
272+
273+
274 def get_channels_manager(db):
275 global channels_manager
276 if channels_manager is None:
277 from softwarecenter.enums import USE_PACKAGEKIT_BACKEND
278 if not USE_PACKAGEKIT_BACKEND:
279- from softwarecenter.backend.channel_impl.aptchannels import AptChannelsManager
280+ from softwarecenter.backend.channel_impl.aptchannels import (
281+ AptChannelsManager)
282 channels_manager = AptChannelsManager(db)
283 else:
284 channels_manager = ChannelsManager(db)
285 return channels_manager
286
287+
288 def is_channel_available(channelname):
289- from softwarecenter.backend.channel_impl.aptchannels import AptChannelsManager
290+ from softwarecenter.backend.channel_impl.aptchannels import (
291+ AptChannelsManager)
292 return AptChannelsManager.channel_available(channelname)
293
294 if __name__ == "__main__":
295 distro = get_distro()
296- channel = SoftwareChannel(distro.get_distro_channel_name(),
297+ channel = SoftwareChannel(distro.get_distro_channel_name(),
298 None, None)
299 print(channel)
300- channel = SoftwareChannel(distro.get_distro_channel_name(), None, "partner")
301+ channel = SoftwareChannel(distro.get_distro_channel_name(), None,
302+ "partner")
303 print(channel)
304-
305
306=== modified file 'softwarecenter/backend/fake_review_settings.py'
307--- softwarecenter/backend/fake_review_settings.py 2011-08-09 08:47:43 +0000
308+++ softwarecenter/backend/fake_review_settings.py 2012-03-19 14:27:20 +0000
309@@ -4,7 +4,8 @@
310 import pickle
311 from softwarecenter.paths import SOFTWARE_CENTER_CACHE_DIR
312
313-# decorator to add a fake network delay if set
314+
315+# decorator to add a fake network delay if set
316 # in FakeReviewSettings.fake_network_delay
317 def network_delay(fn):
318 def slp(self, *args, **kwargs):
319@@ -14,23 +15,25 @@
320 time.sleep(delay)
321 return fn(self, *args, **kwargs)
322 return slp
323-
324+
325+
326 class FakeReviewSettings(object):
327- '''An object that simply holds settings which are used by RatingsAndReviewsAPI
328- in the rnrclient_fake module. Using this module allows a developer to test
329- the reviews functionality without any interaction with a reviews server.
330- Each setting here provides complete control over how the 'server' will
331- respond. Changes to these settings should be made to the class attributes
332- directly without creating an instance of this class.
333- The intended usage is for unit tests where a predictable response is
334- required and where the application should THINK it has spoken to a
335- server.
336- The unit test would make changes to settings in this class before
337+ '''An object that simply holds settings which are used by
338+ RatingsAndReviewsAPI in the rnrclient_fake module. Using this module
339+ allows a developer to test the reviews functionality without any
340+ interaction with a reviews server. Each setting here provides complete
341+ control over how the 'server' will respond. Changes to these settings
342+ should be made to the class attributes directly without creating an
343+ instance of this class.
344+ The intended usage is for unit tests where a predictable response is
345+ required and where the application should THINK it has spoken to a
346+ server.
347+ The unit test would make changes to settings in this class before
348 running the unit test.
349 '''
350-
351+
352 _FAKE_SETTINGS = {}
353-
354+
355 #general settings
356 #*****************************
357 #delay (in seconds) before returning from any of the fake rnr methods
358@@ -41,45 +44,46 @@
359 #*****************************
360 #raises APIError if True
361 _FAKE_SETTINGS['server_response_error'] = False
362-
363+
364 #review stats
365 #*****************************
366 #raises APIError if True
367- _FAKE_SETTINGS['review_stats_error'] = False
368-
369+ _FAKE_SETTINGS['review_stats_error'] = False
370+
371 #the following has no effect if review_stats_error = True
372- #determines the number of package stats (i.e. ReviewStats list size) to return
373- #max 15 packages (any number higher than 15 will still return 15)
374+ #determines the number of package stats (i.e. ReviewStats list size) to
375+ #return max 15 packages (any number higher than 15 will still return 15)
376 _FAKE_SETTINGS['packages_returned'] = 10
377-
378+
379 #get reviews
380 #*****************************
381 #raises APIError if True
382 _FAKE_SETTINGS['get_reviews_error'] = False
383
384- #number of pages of 10 reviews to return before returning the number specified
385- #in the reviews_returned value below
386+ #number of pages of 10 reviews to return before returning the number
387+ # specified in the reviews_returned value below
388 _FAKE_SETTINGS['review_pages'] = 1
389
390 #the following has no effect if get_reviews_error = True
391- #determines number of reviews to return
392+ #determines number of reviews to return
393 # (Accepts 0 to n but should really be between 1 and 10)
394 _FAKE_SETTINGS['reviews_returned'] = 3
395-
396+
397 #get review
398 #*****************************
399 #raises APIError if True
400 _FAKE_SETTINGS['get_review_error'] = False
401-
402+
403 #submit review
404 #*****************************
405 #raises APIError if True
406 _FAKE_SETTINGS['submit_review_error'] = False
407- #fake username(str) and review_id(int) to give back with a successful review
408+ #fake username(str) and review_id(int) to give back with a successful
409+ # review
410 #leave as None to generate a random username and review_id
411 _FAKE_SETTINGS['reviewer_username'] = None
412 _FAKE_SETTINGS['submit_review_id'] = None
413-
414+
415 #flag review
416 #*****************************
417 #raises APIError if True
418@@ -88,43 +92,43 @@
419 _FAKE_SETTINGS['flagger_username'] = None
420 #fake package name (str) to give back as flagged app
421 _FAKE_SETTINGS['flag_package_name'] = None
422-
423+
424 #submit usefulness
425 #*****************************
426 #raises APIError if True
427 _FAKE_SETTINGS['submit_usefulness_error'] = False
428-
429+
430 #the following has no effect if submit_usefulness_error = True
431 #which string to pretend the server returned
432 #choices are "Created", "Updated", "Not modified"
433 _FAKE_SETTINGS['usefulness_response_string'] = "Created"
434-
435+
436 #get usefulness
437 #*****************************
438 #raises APIError if True
439 _FAKE_SETTINGS['get_usefulness_error'] = False
440-
441+
442 #the following has no effect if get_usefulness_error = True
443 #how many usefulness votes to return
444 _FAKE_SETTINGS['votes_returned'] = 5
445-
446- #pre-configured review ids to return in the result
447+
448+ #pre-configured review ids to return in the result
449 #if you don't complete this or enter less review ids than votes_returned
450 #above, it will be random
451- _FAKE_SETTINGS['required_review_ids'] = [3,6,15]
452-
453+ _FAKE_SETTINGS['required_review_ids'] = [3, 6, 15]
454+
455 #THE FOLLOWING SETTINGS RELATE TO LOGIN SSO FUNCTIONALITY
456 # LoginBackendDbusSSO
457 # login()
458 #***********************
459- # what to fake the login response as
460+ # what to fake the login response as
461 # choices (strings): "successful", "failed", "denied"
462 _FAKE_SETTINGS['login_response'] = "successful"
463-
464+
465 # UbuntuSSOAPI
466 # whoami()
467 #***********************
468- # what to fake whoami response as
469+ # what to fake whoami response as
470 # choices (strings): "whoami", "error"
471 _FAKE_SETTINGS['whoami_response'] = "whoami"
472 #this only has effect if whoami_response = 'whoami'
473@@ -132,65 +136,65 @@
474 #expects a string or None (for a random username)
475 _FAKE_SETTINGS['whoami_username'] = None
476
477-
478 def __init__(self, defaults=False):
479- '''Initialises the object and loads the settings into the _FAKE_SETTINGS
480- dict.. If defaults is passed as True any existing settings in the cache
481- file are ignored and the cache file is overwritten with the defaults
482- set in the class. This is useful if you don't want previously used
483- settings from the cache file being used again'''
484+ '''Initialises the object and loads the settings into the
485+ _FAKE_SETTINGS dict.. If defaults is passed as True any existing
486+ settings in the cache file are ignored and the cache file is
487+ overwritten with the defaults set in the class. This is useful if
488+ you don't want previously used settings from the cache file being
489+ used again'''
490 fname = 'fake_review_settings.p'
491 self.LOCATION = os.path.join(SOFTWARE_CENTER_CACHE_DIR, fname)
492 if defaults:
493 self._save_settings()
494 else:
495 self._update_from_file()
496- return
497-
498+
499 def update_setting(self, key_name, new_value):
500- '''Takes a string (key_name) which corresponds to a setting in this object
501- and updates it with the value passed in (new_value).
502+ '''Takes a string (key_name) which corresponds to a setting in this
503+ object and updates it with the value passed in (new_value).
504 Raises a NameError if the setting name doesn't exist'''
505-
506+
507 if not key_name in self._FAKE_SETTINGS:
508- raise NameError ('Setting key name %s does not exist' % key_name)
509+ raise NameError('Setting key name %s does not exist' % key_name)
510 else:
511 self._FAKE_SETTINGS[key_name] = new_value
512 self._save_settings()
513 return
514-
515+
516 def update_multiple(self, settings):
517- '''Takes a dict (settings) of key,value pairs to perform multiple updates
518- in one action, then saves. Dict being passed should contain only keys that
519- match settings in this object or a NameError will be raised'''
520+ '''Takes a dict (settings) of key,value pairs to perform multiple
521+ updates in one action, then saves. Dict being passed should contain
522+ only keys that match settings in this object or a NameError will be
523+ raised'''
524 for key, value in settings.items():
525 if not key in self._FAKE_SETTINGS:
526- raise NameError ('Setting key name %s does not exist' % key)
527-
528+ raise NameError('Setting key name %s does not exist' % key)
529+
530 for key, value in settings.items():
531 self._FAKE_SETTINGS[key] = value
532 self._save_settings()
533 return
534-
535+
536 def get_setting(self, key_name):
537- '''Takes a string (key_name) which corresponds to a setting in this object,
538- gets the latest copy of it from the file and returns the setting.
539- Raises a NameError if the setting name doesn't exist'''
540+ '''Takes a string (key_name) which corresponds to a setting in this
541+ object, gets the latest copy of it from the file and returns the
542+ setting. Raises a NameError if the setting name doesn't exist'''
543 if not key_name in self._FAKE_SETTINGS:
544- raise NameError ('Setting %s does not exist' % key_name)
545+ raise NameError('Setting %s does not exist' % key_name)
546 else:
547 self._update_from_file()
548 return self._FAKE_SETTINGS[key_name]
549-
550+
551 def _update_from_file(self):
552 '''Loads existing settings from cache file into _FAKE_SETTINGS dict'''
553 if os.path.exists(self.LOCATION):
554 try:
555 self._FAKE_SETTINGS = pickle.load(open(self.LOCATION))
556 except:
557- os.rename(self.LOCATION, self.LOCATION+".fail")
558+ os.rename(self.LOCATION, self.LOCATION + ".fail")
559 return
560-
561+
562 def _save_settings(self):
563 """write the dict out to cache file"""
564 try:
565
566=== modified file 'softwarecenter/backend/installbackend.py'
567--- softwarecenter/backend/installbackend.py 2012-02-07 16:56:40 +0000
568+++ softwarecenter/backend/installbackend.py 2012-03-19 14:27:20 +0000
569@@ -18,32 +18,46 @@
570
571 from softwarecenter.utils import UnimplementedError
572
573+
574 class InstallBackend(object):
575 def __init__(self):
576 self.pending_transactions = {}
577 self.pending_purchases = []
578
579- def upgrade(self, app, iconname, addons_install=[], addons_remove=[], metadata=None):
580- pass
581- def remove(self, app, iconname, addons_install=[], addons_remove=[], metadata=None):
582- pass
583- def remove_multiple(self, apps, iconnames, addons_install=[], addons_remove=[], metadatas=None):
584- pass
585- def install(self, app, iconname, filename=None, addons_install=[], addons_remove=[], metadata=None):
586- pass
587- def install_multiple(self, apps, iconnames, addons_install=[], addons_remove=[], metadatas=None):
588- pass
589- def apply_changes(self, app, iconname, addons_install=[], addons_remove=[], metadata=None):
590- pass
591+ def upgrade(self, app, iconname, addons_install=[], addons_remove=[],
592+ metadata=None):
593+ pass
594+
595+ def remove(self, app, iconname, addons_install=[], addons_remove=[],
596+ metadata=None):
597+ pass
598+
599+ def remove_multiple(self, apps, iconnames, addons_install=[],
600+ addons_remove=[], metadatas=None):
601+ pass
602+
603+ def install(self, app, iconname, filename=None, addons_install=[],
604+ addons_remove=[], metadata=None):
605+ pass
606+
607+ def install_multiple(self, apps, iconnames, addons_install=[],
608+ addons_remove=[], metadatas=None):
609+ pass
610+
611+ def apply_changes(self, app, iconname, addons_install=[],
612+ addons_remove=[], metadata=None):
613+ pass
614+
615 def reload(self, sources_list=None, metadata=None):
616 """ reload package list """
617 pass
618
619+
620 class InstallBackendUI(object):
621
622 def ask_config_file_conflict(self, old, new):
623 """ show a conffile conflict and ask what to do
624- Return "keep" to keep the old one
625+ Return "keep" to keep the old one
626 "replace" to replace the old with the new one
627 """
628 raise UnimplementedError("need custom ask_config_file_conflict method")
629@@ -53,24 +67,27 @@
630 return True if medium is provided, False to cancel
631 """
632 raise UnimplementedError("need custom ask_medium_required method")
633-
634- def error(self, parent, primary, secondary, details=None, alternative_action=None):
635+
636+ def error(self, parent, primary, secondary, details=None,
637+ alternative_action=None):
638 """ show an error dialog """
639 raise UnimplementedError("need custom error method")
640
641
642 # singleton
643 install_backend = None
644+
645+
646 def get_install_backend():
647 global install_backend
648 if install_backend is None:
649 from softwarecenter.enums import USE_PACKAGEKIT_BACKEND
650 if not USE_PACKAGEKIT_BACKEND:
651- from softwarecenter.backend.installbackend_impl.aptd import AptdaemonBackend
652+ from softwarecenter.backend.installbackend_impl.aptd import (
653+ AptdaemonBackend)
654 install_backend = AptdaemonBackend()
655 else:
656- from softwarecenter.backend.installbackend_impl.packagekitd import PackagekitBackend
657+ from softwarecenter.backend.installbackend_impl.packagekitd \
658+ import PackagekitBackend
659 install_backend = PackagekitBackend()
660 return install_backend
661-
662-
663
664=== modified file 'softwarecenter/backend/launchpad.py'
665--- softwarecenter/backend/launchpad.py 2012-02-13 19:56:12 +0000
666+++ softwarecenter/backend/launchpad.py 2012-03-19 14:27:20 +0000
667@@ -35,7 +35,7 @@
668 # py3 compat
669 try:
670 from queue import Queue
671- Queue # pyflakes
672+ Queue # pyflakes
673 except ImportError:
674 from Queue import Queue
675
676@@ -55,16 +55,18 @@
677 LOGIN_STATE_AUTH_FAILURE = "auth-fail"
678 LOGIN_STATE_USER_CANCEL = "user-cancel"
679
680+
681 class UserCancelException(Exception):
682 """ user pressed cancel """
683 pass
684
685+
686 class LaunchpadlibWorker(threading.Thread):
687 """The launchpadlib worker thread - it does not touch the UI
688 and only communicates via the following:
689
690 "login_state" - the current LOGIN_STATE_* value
691-
692+
693 To input reviews call "queue_review()"
694 When no longer needed, call "shutdown()"
695 """
696@@ -128,7 +130,7 @@
697 try:
698 self._launchpad = Launchpad.login_with(
699 'software-center', SERVICE_ROOT, cachedir,
700- allow_access_levels = access_level,
701+ allow_access_levels=access_level,
702 authorizer_class=AuthorizeRequestTokenFromThread)
703 self.display_name = self._launchpad.me.display_name
704 except Exception as e:
705@@ -141,7 +143,8 @@
706 (service_root, launchpadlib_dir, cache_path,
707 service_root_dir) = Launchpad._get_paths(SERVICE_ROOT, cachedir)
708 credentials_path = os.path.join(service_root_dir, 'credentials')
709- consumer_credentials_path = os.path.join(credentials_path, 'software-center')
710+ consumer_credentials_path = os.path.join(credentials_path,
711+ 'software-center')
712 # ---
713 if os.path.exists(consumer_credentials_path):
714 os.remove(consumer_credentials_path)
715@@ -150,11 +153,12 @@
716 self.login_state = LOGIN_STATE_SUCCESS
717 self._logger.debug("/done %s" % self._launchpad)
718
719+
720 class AuthorizeRequestTokenFromThread(RequestTokenAuthorizationEngine):
721 """ Internal helper that updates the login_state of
722 the modul global lp_worker_thread object
723 """
724- def __init__ (self, *args, **kwargs):
725+ def __init__(self, *args, **kwargs):
726 super(AuthorizeRequestTokenFromThread, self).__init__(*args, **kwargs)
727 self._logger = logging.getLogger("softwarecenter.backend")
728
729@@ -167,7 +171,7 @@
730 return o
731
732 def input_username(self, cached_username, suggested_message):
733- self._logger.debug( "input_username: %s" %self.lp_worker.login_state)
734+ self._logger.debug("input_username: %s" % self.lp_worker.login_state)
735 # otherwise go into ASK state
736 if not self.lp_worker.login_state in (LOGIN_STATE_ASK_USER_AND_PASS,
737 LOGIN_STATE_AUTH_FAILURE,
738@@ -185,7 +189,8 @@
739 return self.lp_worker.login_username
740
741 def input_password(self, suggested_message):
742- self._logger.debug( "Input password size %s" % len(self.lp_worker.login_password))
743+ self._logger.debug("Input password size %s" %
744+ len(self.lp_worker.login_password))
745 return self.lp_worker.login_password
746
747 def input_access_level(self, available_levels, suggested_message,
748@@ -217,7 +222,7 @@
749 """
750
751 NEW_ACCOUNT_URL = "https://login.launchpad.net/+standalone-login"
752- FORGOT_PASSWORD_URL = "https://login.launchpad.net/+standalone-login"
753+ FORGOT_PASSWORD_URL = "https://login.launchpad.net/+standalone-login"
754
755 def __init__(self):
756 LoginBackend.__init__(self)
757@@ -238,13 +243,13 @@
758 lp_worker_thread.shutdown()
759
760 def enter_username_password(self, user, password):
761- """
762+ """
763 provider username and password, ususally used when the
764 need-username-password signal was send
765 """
766 lp_worker_thread.login_username = user
767 lp_worker_thread.login_password = password
768- lp_worker_thread.login_state = LOGIN_STATE_HAS_USER_AND_PASS
769+ lp_worker_thread.login_state = LOGIN_STATE_HAS_USER_AND_PASS
770
771 def login(self, username=None, password=None):
772 if username and password:
773@@ -254,17 +259,17 @@
774
775 def cancel_login(self):
776 lp_worker_thread.login_state = LOGIN_STATE_USER_CANCEL
777-
778+
779 def get_subscribed_archives(self):
780 """ return list of sources.list entries """
781 urls = lp_worker_thread._launchpad.me.getArchiveSubscriptionURLs()
782 return self._format_archive_subscription_urls_as_deb_lines(urls)
783-
784+
785 def _format_archive_subscription_urls_as_deb_lines(self, urls):
786 deb_lines = ["deb %s %s main" % (url, self.distro.get_codename()) \
787 for url in urls]
788 return deb_lines
789-
790+
791 def get_subscribed_archives_async(self, callback):
792 """ get the available subscribed archives and run 'callback' when
793 they become availalbe
794@@ -300,10 +305,16 @@
795 print ("success %s" % lp)
796 print(lp.get_subscribed_archives())
797 print(lp.get_subscribed_archives_async(_result_callback))
798+
799+
800 def _login_failed(lp):
801 print ("fail %s" % lp)
802+
803+
804 def _result_callback(result_list):
805 print("_result_callback %s" % result_list)
806+
807+
808 def _login_need_user_and_password(lp):
809 import sys
810 sys.stdout.write("user: ")
811
812=== modified file 'softwarecenter/backend/login.py'
813--- softwarecenter/backend/login.py 2012-01-05 15:01:43 +0000
814+++ softwarecenter/backend/login.py 2012-03-19 14:27:20 +0000
815@@ -21,31 +21,33 @@
816
817 from gi.repository import GObject
818
819+
820 class LoginBackend(GObject.GObject):
821
822 NEW_ACCOUNT_URL = None
823 FORGOT_PASSWORD_URL = None
824
825 __gsignals__ = {
826- "login-successful" : (GObject.SIGNAL_RUN_LAST,
827- GObject.TYPE_NONE,
828+ "login-successful": (GObject.SIGNAL_RUN_LAST,
829+ GObject.TYPE_NONE,
830 (GObject.TYPE_PYOBJECT,),
831 ),
832- "login-failed" : (GObject.SIGNAL_RUN_LAST,
833- GObject.TYPE_NONE,
834- (),
835- ),
836- "login-canceled" : (GObject.SIGNAL_RUN_LAST,
837- GObject.TYPE_NONE,
838- (),
839- ),
840- "need-username-password" : (GObject.SIGNAL_RUN_LAST,
841- GObject.TYPE_NONE,
842- (),
843- ),
844+ "login-failed": (GObject.SIGNAL_RUN_LAST,
845+ GObject.TYPE_NONE,
846+ (),
847+ ),
848+ "login-canceled": (GObject.SIGNAL_RUN_LAST,
849+ GObject.TYPE_NONE,
850+ (),
851+ ),
852+ "need-username-password": (GObject.SIGNAL_RUN_LAST,
853+ GObject.TYPE_NONE,
854+ (),
855+ ),
856 }
857
858 def login(self, username=None, password=None):
859 raise NotImplemented
860+
861 def cancel_login(self):
862 self.emit("login-canceled")
863
864=== modified file 'softwarecenter/backend/login_sso.py'
865--- softwarecenter/backend/login_sso.py 2012-03-14 15:45:47 +0000
866+++ softwarecenter/backend/login_sso.py 2012-03-19 14:27:20 +0000
867@@ -36,6 +36,7 @@
868
869 LOG = logging.getLogger(__name__)
870
871+
872 class LoginBackendDbusSSO(LoginBackend):
873
874 def __init__(self, window_id, appname, help_text):
875@@ -45,11 +46,11 @@
876 self.bus = dbus.SessionBus()
877 self.proxy = self.bus.get_object(
878 'com.ubuntu.sso', '/com/ubuntu/sso/credentials')
879- self.proxy.connect_to_signal("CredentialsFound",
880+ self.proxy.connect_to_signal("CredentialsFound",
881 self._on_credentials_found)
882- self.proxy.connect_to_signal("CredentialsError",
883+ self.proxy.connect_to_signal("CredentialsError",
884 self._on_credentials_error)
885- self.proxy.connect_to_signal("AuthorizationDenied",
886+ self.proxy.connect_to_signal("AuthorizationDenied",
887 self._on_authorization_denied)
888 self._window_id = window_id
889 self._credentials = None
890@@ -66,7 +67,7 @@
891 LOG.debug("login()")
892 self._credentials = None
893 self.proxy.login(self.appname, self._get_params())
894-
895+
896 def login_or_register(self):
897 LOG.debug("login_or_register()")
898 self._credentials = None
899@@ -82,7 +83,6 @@
900 if self._credentials != credentials:
901 self.emit("login-successful", credentials)
902 self._credentials = credentials
903-
904
905 def _on_credentials_error(self, app_name, error, detailed_error=""):
906 LOG.error("_on_credentails_error for %s: %s (%s)" % (
907@@ -107,55 +107,62 @@
908 self.help_text = help_text
909 self._window_id = window_id
910 self._fake_settings = FakeReviewSettings()
911-
912+
913 @network_delay
914 def login(self, username=None, password=None):
915 response = self._fake_settings.get_setting('login_response')
916-
917+
918 if response == "successful":
919 self.emit("login-successful", self._return_credentials())
920 elif response == "failed":
921 self.emit("login-failed")
922 elif response == "denied":
923 self.cancel_login()
924-
925+
926 return
927-
928+
929 def login_or_register(self):
930 #fake functionality for this is no different to fake login()
931 self.login()
932 return
933-
934+
935 def _random_unicode_string(self, length):
936 retval = ''
937- for i in range(0,length):
938+ for i in range(0, length):
939 retval = retval + random.choice(string.letters + string.digits)
940 return retval.decode('utf-8')
941-
942+
943 def _return_credentials(self):
944- c = dbus.Dictionary(
945+ c = dbus.Dictionary(
946 {
947- dbus.String(u'consumer_secret'): dbus.String(self._random_unicode_string(30)),
948- dbus.String(u'token') : dbus.String(self._random_unicode_string(50)),
949- dbus.String(u'consumer_key') : dbus.String(self._random_unicode_string(7)),
950- dbus.String(u'name') : dbus.String('Ubuntu Software Center @ ' + self._random_unicode_string(6)),
951- dbus.String(u'token_secret') : dbus.String(self._random_unicode_string(50))
952- },
953+ dbus.String(u'consumer_secret'): dbus.String(
954+ self._random_unicode_string(30)),
955+ dbus.String(u'token'): dbus.String(
956+ self._random_unicode_string(50)),
957+ dbus.String(u'consumer_key'): dbus.String(
958+ self._random_unicode_string(7)),
959+ dbus.String(u'name'): dbus.String('Ubuntu Software Center @ ' +
960+ self._random_unicode_string(6)),
961+ dbus.String(u'token_secret'): dbus.String(
962+ self._random_unicode_string(50))
963+ },
964 signature=dbus.Signature('ss')
965 )
966 return c
967
968+
969 def get_sso_backend(window_id, appname, help_text):
970- """
971+ """
972 factory that returns an sso loader singelton
973 """
974 if "SOFTWARE_CENTER_FAKE_REVIEW_API" in os.environ:
975 sso_class = LoginBackendDbusSSOFake(window_id, appname, help_text)
976- LOG.warn('Using fake login SSO functionality. Only meant for testing purposes')
977+ LOG.warn('Using fake login SSO functionality. Only meant for '
978+ 'testing purposes')
979 else:
980 sso_class = LoginBackendDbusSSO(window_id, appname, help_text)
981 return sso_class
982-
983+
984 if __name__ == "__main__":
985 logging.basicConfig(level=logging.DEBUG)
986
987
988=== modified file 'softwarecenter/backend/recagent.py'
989--- softwarecenter/backend/recagent.py 2012-03-12 21:28:10 +0000
990+++ softwarecenter/backend/recagent.py 2012-03-19 14:27:20 +0000
991@@ -31,47 +31,48 @@
992
993 LOG = logging.getLogger(__name__)
994
995+
996 class RecommenderAgent(GObject.GObject):
997
998 __gsignals__ = {
999- "server-status" : (GObject.SIGNAL_RUN_LAST,
1000- GObject.TYPE_NONE,
1001- (GObject.TYPE_PYOBJECT,),
1002- ),
1003- "profile" : (GObject.SIGNAL_RUN_LAST,
1004- GObject.TYPE_NONE,
1005- (GObject.TYPE_PYOBJECT,),
1006- ),
1007- "submit-profile-finished" : (GObject.SIGNAL_RUN_LAST,
1008- GObject.TYPE_NONE,
1009- (GObject.TYPE_PYOBJECT, str),
1010- ),
1011- "submit-anon-profile-finished" : (GObject.SIGNAL_RUN_LAST,
1012- GObject.TYPE_NONE,
1013- (GObject.TYPE_PYOBJECT,),
1014- ),
1015- "recommend-me" : (GObject.SIGNAL_RUN_LAST,
1016- GObject.TYPE_NONE,
1017- (GObject.TYPE_PYOBJECT,),
1018- ),
1019- "recommend-app" : (GObject.SIGNAL_RUN_LAST,
1020- GObject.TYPE_NONE,
1021- (GObject.TYPE_PYOBJECT,),
1022- ),
1023- "recommend-all-apps" : (GObject.SIGNAL_RUN_LAST,
1024- GObject.TYPE_NONE,
1025- (GObject.TYPE_PYOBJECT,),
1026- ),
1027- "recommend-top" : (GObject.SIGNAL_RUN_LAST,
1028- GObject.TYPE_NONE,
1029- (GObject.TYPE_PYOBJECT,),
1030- ),
1031- "error" : (GObject.SIGNAL_RUN_LAST,
1032- GObject.TYPE_NONE,
1033- (str,),
1034- ),
1035+ "server-status": (GObject.SIGNAL_RUN_LAST,
1036+ GObject.TYPE_NONE,
1037+ (GObject.TYPE_PYOBJECT,),
1038+ ),
1039+ "profile": (GObject.SIGNAL_RUN_LAST,
1040+ GObject.TYPE_NONE,
1041+ (GObject.TYPE_PYOBJECT,),
1042+ ),
1043+ "submit-profile-finished": (GObject.SIGNAL_RUN_LAST,
1044+ GObject.TYPE_NONE,
1045+ (GObject.TYPE_PYOBJECT, str),
1046+ ),
1047+ "submit-anon-profile-finished": (GObject.SIGNAL_RUN_LAST,
1048+ GObject.TYPE_NONE,
1049+ (GObject.TYPE_PYOBJECT,),
1050+ ),
1051+ "recommend-me": (GObject.SIGNAL_RUN_LAST,
1052+ GObject.TYPE_NONE,
1053+ (GObject.TYPE_PYOBJECT,),
1054+ ),
1055+ "recommend-app": (GObject.SIGNAL_RUN_LAST,
1056+ GObject.TYPE_NONE,
1057+ (GObject.TYPE_PYOBJECT,),
1058+ ),
1059+ "recommend-all-apps": (GObject.SIGNAL_RUN_LAST,
1060+ GObject.TYPE_NONE,
1061+ (GObject.TYPE_PYOBJECT,),
1062+ ),
1063+ "recommend-top": (GObject.SIGNAL_RUN_LAST,
1064+ GObject.TYPE_NONE,
1065+ (GObject.TYPE_PYOBJECT,),
1066+ ),
1067+ "error": (GObject.SIGNAL_RUN_LAST,
1068+ GObject.TYPE_NONE,
1069+ (str,),
1070+ ),
1071 }
1072-
1073+
1074 def __init__(self, xid=None):
1075 GObject.GObject.__init__(self)
1076 self.xid = xid
1077@@ -86,17 +87,17 @@
1078 spawner.connect("error", lambda spawner, err: self.emit("error", err))
1079 spawner.run_generic_piston_helper(
1080 "SoftwareCenterRecommenderAPI", "server_status")
1081-
1082+
1083 def post_submit_profile(self, db):
1084 """ This will post the users profile to the recommender server
1085- and also generate the UUID for the user if that is not
1086+ and also generate the UUID for the user if that is not
1087 there yet
1088 """
1089 # if we have not already set a recommender UUID, now is the time
1090 # to do it
1091 if not self.recommender_uuid:
1092 self.recommender_uuid = get_uuid()
1093- installed_pkglist = [app.pkgname
1094+ installed_pkglist = [app.pkgname
1095 for app in get_installed_apps_list(db)]
1096 data = self._generate_submit_profile_data(self.recommender_uuid,
1097 installed_pkglist)
1098@@ -110,7 +111,7 @@
1099 "SoftwareCenterRecommenderAPI",
1100 "submit_profile",
1101 data=data)
1102-
1103+
1104 def post_submit_anon_profile(self, uuid, installed_packages, extra):
1105 # build the command
1106 spawner = SpawnHelper()
1107@@ -124,7 +125,7 @@
1108 uuid=uuid,
1109 installed_packages=installed_packages,
1110 extra=extra)
1111-
1112+
1113 def query_profile(self, pkgnames):
1114 # build the command
1115 spawner = SpawnHelper()
1116@@ -146,7 +147,7 @@
1117 spawner.connect("error", lambda spawner, err: self.emit("error", err))
1118 spawner.run_generic_piston_helper(
1119 "SoftwareCenterRecommenderAPI", "recommend_me")
1120-
1121+
1122 def query_recommend_app(self, pkgname):
1123 # build the command
1124 spawner = SpawnHelper()
1125@@ -157,7 +158,7 @@
1126 "SoftwareCenterRecommenderAPI",
1127 "recommend_app",
1128 pkgname=pkgname)
1129-
1130+
1131 def query_recommend_all_apps(self):
1132 # build the command
1133 spawner = SpawnHelper()
1134@@ -166,7 +167,7 @@
1135 spawner.connect("error", lambda spawner, err: self.emit("error", err))
1136 spawner.run_generic_piston_helper(
1137 "SoftwareCenterRecommenderAPI", "recommend_all_apps")
1138-
1139+
1140 def query_recommend_top(self):
1141 # build the command
1142 spawner = SpawnHelper()
1143@@ -175,7 +176,7 @@
1144 spawner.connect("error", lambda spawner, err: self.emit("error", err))
1145 spawner.run_generic_piston_helper(
1146 "SoftwareCenterRecommenderAPI", "recommend_top")
1147-
1148+
1149 def is_opted_in(self):
1150 """
1151 Return True is the user is currently opted-in to the recommender
1152@@ -185,33 +186,34 @@
1153 return True
1154 else:
1155 return False
1156-
1157+
1158 def _on_server_status_data(self, spawner, piston_server_status):
1159 self.emit("server-status", piston_server_status)
1160-
1161+
1162 def _on_profile_data(self, spawner, piston_profile):
1163 self.emit("profile", piston_profile)
1164-
1165+
1166 def _on_submit_profile_data(self, spawner, piston_submit_profile):
1167- self.emit("submit-profile-finished",
1168- piston_submit_profile,
1169+ self.emit("submit-profile-finished",
1170+ piston_submit_profile,
1171 self.recommender_uuid)
1172-
1173- def _on_submit_anon_profile_data(self, spawner, piston_submit_anon_profile):
1174+
1175+ def _on_submit_anon_profile_data(self, spawner,
1176+ piston_submit_anon_profile):
1177 self.emit("submit-anon_profile", piston_submit_anon_profile)
1178
1179 def _on_recommend_me_data(self, spawner, piston_me_apps):
1180 self.emit("recommend-me", piston_me_apps)
1181-
1182+
1183 def _on_recommend_app_data(self, spawner, piston_app):
1184 self.emit("recommend-app", piston_app)
1185-
1186+
1187 def _on_recommend_all_apps_data(self, spawner, piston_all_apps):
1188 self.emit("recommend-all-apps", piston_all_apps)
1189-
1190+
1191 def _on_recommend_top_data(self, spawner, piston_top_apps):
1192 self.emit("recommend-top", piston_top_apps)
1193-
1194+
1195 def _get_recommender_uuid(self):
1196 """ returns the recommender UUID value, which can be empty if it
1197 has not yet been set (indicating that the user has not yet
1198@@ -223,24 +225,24 @@
1199 if recommender_uuid:
1200 return recommender_uuid
1201 return ""
1202-
1203+
1204 def _generate_submit_profile_data(self, recommender_uuid, package_list):
1205- submit_profile_data = [
1206- {
1207- 'uuid': recommender_uuid,
1208- 'package_list': package_list
1209- }
1210- ]
1211+ submit_profile_data = [{
1212+ 'uuid': recommender_uuid,
1213+ 'package_list': package_list
1214+ }]
1215 return submit_profile_data
1216
1217-
1218+
1219 if __name__ == "__main__":
1220 from gi.repository import Gtk
1221
1222 def _recommend_top(agent, top_apps):
1223 print ("_recommend_top: %s" % top_apps)
1224+
1225 def _recommend_me(agent, top_apps):
1226 print ("_recommend_me: %s" % top_apps)
1227+
1228 def _error(agent, msg):
1229 print ("got a error: %s" % msg)
1230 Gtk.main_quit()
1231@@ -256,5 +258,4 @@
1232 agent.query_recommend_top()
1233 agent.query_recommend_me()
1234
1235-
1236 Gtk.main()
1237
1238=== modified file 'softwarecenter/backend/scagent.py'
1239--- softwarecenter/backend/scagent.py 2012-01-17 15:56:14 +0000
1240+++ softwarecenter/backend/scagent.py 2012-03-19 14:27:20 +0000
1241@@ -29,27 +29,28 @@
1242
1243 LOG = logging.getLogger(__name__)
1244
1245+
1246 class SoftwareCenterAgent(GObject.GObject):
1247
1248 __gsignals__ = {
1249- "available-for-me" : (GObject.SIGNAL_RUN_LAST,
1250- GObject.TYPE_NONE,
1251- (GObject.TYPE_PYOBJECT,),
1252- ),
1253- "available" : (GObject.SIGNAL_RUN_LAST,
1254- GObject.TYPE_NONE,
1255- (GObject.TYPE_PYOBJECT,),
1256- ),
1257- "exhibits" : (GObject.SIGNAL_RUN_LAST,
1258- GObject.TYPE_NONE,
1259- (GObject.TYPE_PYOBJECT,),
1260- ),
1261- "error" : (GObject.SIGNAL_RUN_LAST,
1262- GObject.TYPE_NONE,
1263- (str,),
1264- ),
1265+ "available-for-me": (GObject.SIGNAL_RUN_LAST,
1266+ GObject.TYPE_NONE,
1267+ (GObject.TYPE_PYOBJECT,),
1268+ ),
1269+ "available": (GObject.SIGNAL_RUN_LAST,
1270+ GObject.TYPE_NONE,
1271+ (GObject.TYPE_PYOBJECT,),
1272+ ),
1273+ "exhibits": (GObject.SIGNAL_RUN_LAST,
1274+ GObject.TYPE_NONE,
1275+ (GObject.TYPE_PYOBJECT,),
1276+ ),
1277+ "error": (GObject.SIGNAL_RUN_LAST,
1278+ GObject.TYPE_NONE,
1279+ (str,),
1280+ ),
1281 }
1282-
1283+
1284 def __init__(self, ignore_cache=False, xid=None):
1285 GObject.GObject.__init__(self)
1286 self.distro = get_distro()
1287@@ -103,7 +104,8 @@
1288 "SoftwareCenterAgentAPI", "subscriptions_for_me",
1289 complete_only=True)
1290
1291- def _on_query_available_for_me_data(self, spawner, piston_available_for_me):
1292+ def _on_query_available_for_me_data(self, spawner,
1293+ piston_available_for_me):
1294 self.emit("available-for-me", piston_available_for_me)
1295
1296 def query_exhibits(self):
1297@@ -113,7 +115,7 @@
1298 spawner.connect("data-available", self._on_exhibits_data_available)
1299 spawner.connect("error", lambda spawner, err: self.emit("error", err))
1300 spawner.run_generic_piston_helper(
1301- "SoftwareCenterAgentAPI", "exhibits",
1302+ "SoftwareCenterAgentAPI", "exhibits",
1303 lang=get_language(), series=self.distro.get_codename())
1304
1305 def _on_exhibits_data_available(self, spawner, exhibits):
1306@@ -123,18 +125,22 @@
1307 if not hasattr(exhibit, "title_translated"):
1308 if exhibit.html:
1309 from softwarecenter.utils import get_title_from_html
1310- exhibit.title_translated = get_title_from_html(exhibit.html)
1311+ exhibit.title_translated = get_title_from_html(
1312+ exhibit.html)
1313 else:
1314 exhibit.title_translated = ""
1315 self.emit("exhibits", exhibits)
1316-
1317+
1318 if __name__ == "__main__":
1319 def _available(agent, available):
1320 print ("_available: %s" % available)
1321+
1322 def _available_for_me(agent, available_for_me):
1323 print ("_availalbe_for_me: %s" % available_for_me)
1324+
1325 def _exhibits(agent, exhibits):
1326 print ("exhibits: " % exhibits)
1327+
1328 def _error(agent, msg):
1329 print ("got a error" % msg)
1330 #gtk.main_quit()
1331
1332=== modified file 'softwarecenter/hw.py'
1333--- softwarecenter/hw.py 2012-03-19 11:32:58 +0000
1334+++ softwarecenter/hw.py 2012-03-19 14:27:20 +0000
1335@@ -79,10 +79,12 @@
1336 u'computer is using.'),
1337 }
1338
1339+
1340 def get_hw_short_description(tag):
1341 s = TAG_DESCRIPTION.get(tag)
1342 return utf8(s)
1343
1344+
1345 def get_hw_missing_long_description(tags):
1346 s = ""
1347 # build string
1348@@ -94,7 +96,7 @@
1349 else:
1350 # deal with generic tags
1351 prefix, sep, postfix = tag.rpartition(":")
1352- descr = TAG_MISSING_DESCRIPTION.get(prefix+sep)
1353+ descr = TAG_MISSING_DESCRIPTION.get(prefix + sep)
1354 descr = descr % postfix
1355 if descr:
1356 s += "%s\n" % descr
1357@@ -116,8 +118,9 @@
1358 res[tag] = debtagshw.enums.HardwareSupported.YES
1359 return res
1360
1361+
1362 def get_hardware_support_for_tags(tags):
1363- """ wrapper around the DebtagsAvailalbeHW to support adding our own
1364+ """ wrapper around the DebtagsAvailalbeHW to support adding our own
1365 private tag extension (like opengl-driver)
1366 """
1367 from debtagshw.debtagshw import DebtagsAvailableHW
1368
1369=== modified file 'softwarecenter/testutils.py'
1370--- softwarecenter/testutils.py 2012-03-15 21:19:02 +0000
1371+++ softwarecenter/testutils.py 2012-03-19 14:27:20 +0000
1372@@ -230,7 +230,7 @@
1373 },
1374 {
1375 u'package_name': u'mangler'
1376- },
1377+ },
1378 {
1379 u'package_name': u'nexuiz'
1380 },
1381@@ -254,7 +254,7 @@
1382 },
1383 {
1384 u'package_name': u'psi'
1385- },
1386+ },
1387 {
1388 u'package_name': u'midori'
1389 }
1390@@ -282,7 +282,6 @@
1391 u'phlipple',
1392 u'psi',
1393 u'midori'
1394-
1395 ]
1396 }
1397 ]
1398
1399=== modified file 'softwarecenter/utils.py'
1400--- softwarecenter/utils.py 2012-03-16 17:22:59 +0000
1401+++ softwarecenter/utils.py 2012-03-19 14:27:20 +0000
1402@@ -253,7 +253,7 @@
1403 # well ... it segfaults (thanks pygi)
1404 key = "org.gnome.system.proxy.http"
1405 if not key in Gio.Settings.list_schemas():
1406- raise ValueError, "no key '%s'" % key
1407+ raise ValueError("no key '%s'" % key)
1408 settings = Gio.Settings.new(key)
1409 if settings.get_string("host"):
1410 authentication = ""
1411
1412=== modified file 'test/test_pep8.py'
1413--- test/test_pep8.py 2012-03-19 14:27:20 +0000
1414+++ test/test_pep8.py 2012-03-19 14:27:20 +0000
1415@@ -7,21 +7,12 @@
1416 setup_test_env()
1417
1418 # Only test these two packages for now:
1419-import softwarecenter.backend
1420-import softwarecenter.db
1421-import softwarecenter.ui
1422-import softwarecenter.distro
1423+import softwarecenter
1424
1425 class PackagePep8TestCase(unittest.TestCase):
1426 maxDiff = None
1427- packages = [softwarecenter.ui,
1428- softwarecenter.backend,
1429- softwarecenter.db,
1430- softwarecenter.distro,
1431- ]
1432- exclude = ['scagent.py', 'recagent.py', 'login_sso.py', 'login.py',
1433- 'launchpad.py', 'installbackend.py', 'fake_review_settings.py',
1434- 'channel.py']
1435+ packages = [softwarecenter]
1436+ exclude = []
1437
1438 def message(self, text):
1439 self.errors.append(text)