Merge lp:~mvo/software-center/proper-error-on-unknown-files into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merge reported by: Gary Lasker
Merged at revision: not available
Proposed branch: lp:~mvo/software-center/proper-error-on-unknown-files
Merge into: lp:software-center
Diff against target: 101 lines (+38/-11)
4 files modified
debian/changelog (+10/-4)
softwarecenter/ui/gtk3/app.py (+12/-3)
softwarecenter/ui/gtk3/models/appstore2.py (+8/-0)
softwarecenter/ui/gtk3/views/appdetailsview.py (+8/-4)
To merge this branch: bzr merge lp:~mvo/software-center/proper-error-on-unknown-files
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+104656@code.launchpad.net

Description of the change

This branch is a fix for a error from errors.ubuntu.com when people run software-center on a unknown/unhandeled
filetype. To test:
1. touch foo
2. software-center foo
3. crash

With this branch you get a nice error message without a string change, the code reuses existing strings.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Does the trick! I tested with both valid and invalid file types. Thank you, Michael!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-04-30 22:27:29 +0000
3+++ debian/changelog 2012-05-04 00:48:18 +0000
4@@ -1,12 +1,18 @@
5-*** DO NOT UPLOAD YET FROM THIS BRANCH, use the lp:software-center/5.2
6- BRANCH INSTEAD until "quantal" gets the first upload ***
7-
8-software-center (5.3.0) UNRELEASED; urgency=low
9+software-center (5.2.2) UNRELEASED; urgency=low
10
11 [ Michael Vogt ]
12 * lp:~mvo/software-center/whatsnew-leak-lp985389:
13 - search filter fix for the case when the "installed-only"
14 filter leaks into subsequent searches (LP: #985389)
15+
16+ [ Gary Lasker ]
17+ * lp:~gary-lasker/software-center/fix-crash-lp969732:
18+ - need to explicitly declare the needs-refresh signal in the
19+ AppTreeStore class to prevent a crash (LP: #969732)
20+ * lp:~gary-lasker/software-center/fix-crash-lp870822:
21+ - don't crash if we don't get a pkgversion object back
22+ (LP: #870822)
23+
24
25 -- Gary Lasker <gary.lasker@canonical.com> Mon, 30 Apr 2012 18:22:04 -0400
26
27
28=== modified file 'softwarecenter/ui/gtk3/app.py'
29--- softwarecenter/ui/gtk3/app.py 2012-04-25 08:26:43 +0000
30+++ softwarecenter/ui/gtk3/app.py 2012-05-04 00:48:18 +0000
31@@ -1240,7 +1240,15 @@
32 if not request.startswith('/'):
33 # we may have been given a relative path
34 request = os.path.join(os.getcwd(), request)
35- app = DebFileApplication(request)
36+ try:
37+ app = DebFileApplication(request)
38+ except ValueError as e:
39+ LOG.error("can not open %s: %s" % (request, e))
40+ from softwarecenter.ui.gtk3.dialogs import error
41+ error(None,
42+ _("Error"),
43+ _("The file ā€œ%sā€ could not be opened.") % request)
44+ app = None
45 else:
46 # package from archive
47 # if there is a "/" in the string consider it as tuple
48@@ -1261,8 +1269,9 @@
49 else:
50 self.available_pane.init_view()
51 self.available_pane.show_app(app)
52- show_app(self, app)
53- return
54+ if app:
55+ show_app(self, app)
56+ return
57 elif len(packages) > 1:
58 # turn multiple packages into a search with ","
59 self.available_pane.init_view()
60
61=== modified file 'softwarecenter/ui/gtk3/models/appstore2.py'
62--- softwarecenter/ui/gtk3/models/appstore2.py 2012-03-30 09:11:08 +0000
63+++ softwarecenter/ui/gtk3/models/appstore2.py 2012-05-04 00:48:18 +0000
64@@ -476,6 +476,14 @@
65 """ A treestore based application model
66 """
67
68+ __gsignals__ = {
69+ # meh, this is a signal from AppPropertiesHelper
70+ "needs-refresh": (GObject.SignalFlags.RUN_LAST,
71+ None,
72+ (str, ),
73+ ),
74+ }
75+
76 def __init__(self, db, cache, icons, icon_size=AppGenericStore.ICON_SIZE,
77 global_icon_cache=True):
78 AppGenericStore.__init__(
79
80=== modified file 'softwarecenter/ui/gtk3/views/appdetailsview.py'
81--- softwarecenter/ui/gtk3/views/appdetailsview.py 2012-04-18 10:31:00 +0000
82+++ softwarecenter/ui/gtk3/views/appdetailsview.py 2012-05-04 00:48:18 +0000
83@@ -2024,10 +2024,14 @@
84 self.app_details.pkg_state == PkgStates.INSTALLED and
85 not self.addons_manager.addons_to_install and
86 not self.addons_manager.addons_to_remove):
87- pkg = self.cache[self.app_details.pkgname].installed
88- install_size = GLib.format_size(pkg.installed_size)
89- # FIXME: this is not really a good indication of the size on disk
90- label_string += _("%s on disk") % (install_size)
91+ pkg_version = self.cache[self.app_details.pkgname].installed
92+ # we may not always get a pkg_version returned (LP: #870822),
93+ # in that case, we'll just have to display "Unknown"
94+ if pkg_version:
95+ install_size = GLib.format_size(pkg_version.installed_size)
96+ # FIXME: this is not really a good indication of the size
97+ # on disk
98+ label_string += _("%s on disk") % (install_size)
99 elif total_install_size < 0:
100 remove_size = GLib.format_size(-total_install_size)
101 label_string += _("%s to be freed") % (remove_size)

Subscribers

People subscribed via source and target branches