Merge lp:~evfool/software-properties/lp1058072 into lp:software-properties

Proposed by Robert Roth
Status: Merged
Merged at revision: 822
Proposed branch: lp:~evfool/software-properties/lp1058072
Merge into: lp:software-properties
Diff against target: 187 lines (+19/-25)
1 file modified
softwareproperties/gtk/SoftwarePropertiesGtk.py (+19/-25)
To merge this branch: bzr merge lp:~evfool/software-properties/lp1058072
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Approve
Review via email: mp+135760@code.launchpad.net

Description of the change

Do not show an authentication dialog, but do not fail with a stacktrace, just silently swallow the denied exception caused by canceling the dialog.

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

I would prefer that instead of a totally silently failing, that we log something on stderr. What do you think?

review: Needs Fixing
823. By

Added error logging in case auth dialog is canceled

Revision history for this message
Robert Roth (evfool) wrote :

Updated the proposal with error logging (using logging.error) instead of silently ignoring.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Thanks a lot! Merging :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwareproperties/gtk/SoftwarePropertiesGtk.py'
2--- softwareproperties/gtk/SoftwarePropertiesGtk.py 2012-09-11 12:26:25 +0000
3+++ softwareproperties/gtk/SoftwarePropertiesGtk.py 2012-11-23 09:26:19 +0000
4@@ -33,6 +33,7 @@
5 import subprocess
6 from aptdaemon import client
7 from aptdaemon.errors import NotAuthorizedError, TransactionFailed
8+import logging
9
10 from gi.repository import GObject, Gdk, Gtk, Gio
11
12@@ -81,12 +82,6 @@
13 dialog.destroy()
14 return False
15
16-# using this often, so defining it here.
17-def permission_denied_dialog(parent_window):
18- error(parent_window,
19- _("Authorization failed."),
20- _("Software sources can't be changed without permission."))
21-
22 class SoftwarePropertiesGtk(SoftwareProperties,SimpleGtkbuilderApp):
23
24 def __init__(self, datadir=None, options=None, file=None, parent=None):
25@@ -464,7 +459,7 @@
26 self.backend.SetUpdateAutomationLevel(state)
27 except dbus.DBusException as e:
28 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
29- permission_denied_dialog(self.window_main)
30+ logging.error("Authentication canceled, changes have not been saved")
31
32 def set_other_update_automation_level(self, widget):
33 """Set the other update automation level to the given value via gconf"""
34@@ -486,7 +481,7 @@
35 self.backend.SetReleaseUpgradesPolicy(i)
36 except dbus.DBusException as e:
37 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
38- permission_denied_dialog(self.window_main)
39+ logging.error("Authentication canceled, changes have not been saved")
40
41 def on_combobox_server_changed(self, combobox):
42 """
43@@ -515,7 +510,7 @@
44 self.backend.ChangeMainDownloadServer(uri)
45 except dbus.DBusException as e:
46 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
47- permission_denied_dialog(self.window_main)
48+ logging.error("Authentication canceled, changes have not been saved")
49
50 # mvo: is this still needed?
51 #else:
52@@ -533,7 +528,7 @@
53 self.backend.DisableComponent(comp)
54 except dbus.DBusException as e:
55 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
56- permission_denied_dialog(self.window_main)
57+ logging.error("Authentication canceled, changes have not been saved")
58
59 def on_checkbutton_child_toggled(self, checkbutton, template):
60 """
61@@ -546,7 +541,7 @@
62 self.backend.EnableChildSource(template.name)
63 except dbus.DBusException as e:
64 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
65- permission_denied_dialog(self.window_main)
66+ logging.error("Authentication canceled, changes have not been saved")
67
68 def on_checkbutton_source_code_toggled(self, checkbutton):
69 """ Disable or enable the source code for all sources """
70@@ -557,7 +552,7 @@
71 self.backend.DisableSourceCodeSources()
72 except dbus.DBusException as e:
73 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
74- permission_denied_dialog(self.window_main)
75+ logging.error("Authentication canceled, changes have not been saved")
76
77 def on_checkbutton_popcon_toggled(self, widget):
78 """ The user clicked on the popcon paritipcation button """
79@@ -568,7 +563,7 @@
80 self.backend.SetPopconPariticipation(widget.get_active())
81 except dbus.DBusException as e:
82 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
83- permission_denied_dialog(self.window_main)
84+ logging.error("Authentication canceled, changes have not been saved")
85
86 def open_file(self, file):
87 """Show a confirmation for adding the channels of the specified file"""
88@@ -587,7 +582,7 @@
89 self.backend.AddSourceFromLine(str(source))
90 except dbus.DBusException as e:
91 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
92- permission_denied_dialog(self.window_main)
93+ logging.error("Authentication canceled, changes have not been saved")
94
95 def on_sources_drag_data_received(self, widget, context, x, y,
96 selection, target_type, timestamp):
97@@ -694,8 +689,7 @@
98 self.backend.ToggleSourceUse(str(source_entry))
99 except dbus.DBusException as e:
100 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
101- permission_denied_dialog(self.window_main)
102-
103+ logging.error("Authentication canceled, changes have not been saved")
104 def init_keys(self):
105 """Setup the user interface parts needed for the key handling"""
106 self.keys_store = Gtk.ListStore(str)
107@@ -753,7 +747,7 @@
108 self.backend.Revert()
109 except dbus.DBusException as e:
110 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
111- permission_denied_dialog(self.window_main)
112+ logging.error("Authentication canceled, changes have not been saved")
113 if self.settings:
114 self.settings.set_int("regular-auto-launch-interval", self.initial_auto_launch)
115 self.show_auto_update_level()
116@@ -837,7 +831,7 @@
117 self.backend.SetUpdateInterval(value)
118 except dbus.DBusException as e:
119 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
120- permission_denied_dialog(self.window_main)
121+ logging.error("Authentication canceled, changes have not been saved")
122
123 def on_add_clicked(self, widget):
124 """Show a dialog that allows to enter the apt line of a to be used repo"""
125@@ -849,7 +843,7 @@
126 self.backend.AddSourceFromLine(line)
127 except dbus.DBusException as e:
128 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
129- permission_denied_dialog(self.window_main)
130+ logging.error("Authentication canceled, changes have not been saved")
131
132 def on_edit_clicked(self, widget):
133 """Show a dialog to edit an ISV source"""
134@@ -866,7 +860,7 @@
135 str(dialog.new_source_entry))
136 except dbus.DBusException as e:
137 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
138- permission_denied_dialog(self.window_main)
139+ logging.error("Authentication canceled, changes have not been saved")
140
141 # FIXME:outstanding from merge
142 def on_isv_source_activated(self, treeview, path, column):
143@@ -907,7 +901,7 @@
144 self.backend.RemoveSource(str(source_entry))
145 except dbus.DBusException as e:
146 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
147- permission_denied_dialog(self.window_main)
148+ logging.error("Authentication canceled, changes have not been saved")
149
150 def add_key_clicked(self, widget):
151 """Provide a file chooser that allows to add the gnupg of a trusted
152@@ -931,7 +925,7 @@
153 "or it might be corrupt."))
154 except dbus.DBusException as e:
155 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
156- permission_denied_dialog(self.window_main)
157+ logging.error("Authentication canceled, changes have not been saved")
158
159 def remove_key_clicked(self, widget):
160 """Remove a trusted software vendor key"""
161@@ -948,7 +942,7 @@
162 "Please report this as a bug."))
163 except dbus.DBusException as e:
164 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
165- permission_denied_dialog(self.window_main)
166+ logging.error("Authentication canceled, changes have not been saved")
167
168 def on_restore_clicked(self, widget):
169 """Restore the original keys"""
170@@ -956,7 +950,7 @@
171 self.backend.UpdateKeys()
172 except dbus.DBusException as e:
173 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
174- permission_denied_dialog(self.window_main)
175+ logging.error("Authentication canceled, changes have not been saved")
176
177 def on_delete_event(self, widget, args):
178 """Close the window if requested"""
179@@ -978,7 +972,7 @@
180 self.backend.AddCdromSource()
181 except dbus.DBusException as e:
182 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
183- permission_denied_dialog(self.window_main)
184+ logging.error("Authentication canceled, changes have not been saved")
185
186 def on_driver_changes_progress(self, transaction, progress):
187 #print(progress)

Subscribers

People subscribed via source and target branches

to status/vote changes: