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
=== modified file 'softwareproperties/gtk/SoftwarePropertiesGtk.py'
--- softwareproperties/gtk/SoftwarePropertiesGtk.py 2012-09-11 12:26:25 +0000
+++ softwareproperties/gtk/SoftwarePropertiesGtk.py 2012-11-23 09:26:19 +0000
@@ -33,6 +33,7 @@
33import subprocess33import subprocess
34from aptdaemon import client34from aptdaemon import client
35from aptdaemon.errors import NotAuthorizedError, TransactionFailed35from aptdaemon.errors import NotAuthorizedError, TransactionFailed
36import logging
3637
37from gi.repository import GObject, Gdk, Gtk, Gio38from gi.repository import GObject, Gdk, Gtk, Gio
3839
@@ -81,12 +82,6 @@
81 dialog.destroy()82 dialog.destroy()
82 return False83 return False
8384
84# using this often, so defining it here.
85def permission_denied_dialog(parent_window):
86 error(parent_window,
87 _("Authorization failed."),
88 _("Software sources can't be changed without permission."))
89
90class SoftwarePropertiesGtk(SoftwareProperties,SimpleGtkbuilderApp):85class SoftwarePropertiesGtk(SoftwareProperties,SimpleGtkbuilderApp):
9186
92 def __init__(self, datadir=None, options=None, file=None, parent=None):87 def __init__(self, datadir=None, options=None, file=None, parent=None):
@@ -464,7 +459,7 @@
464 self.backend.SetUpdateAutomationLevel(state)459 self.backend.SetUpdateAutomationLevel(state)
465 except dbus.DBusException as e:460 except dbus.DBusException as e:
466 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':461 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
467 permission_denied_dialog(self.window_main)462 logging.error("Authentication canceled, changes have not been saved")
468 463
469 def set_other_update_automation_level(self, widget):464 def set_other_update_automation_level(self, widget):
470 """Set the other update automation level to the given value via gconf"""465 """Set the other update automation level to the given value via gconf"""
@@ -486,7 +481,7 @@
486 self.backend.SetReleaseUpgradesPolicy(i)481 self.backend.SetReleaseUpgradesPolicy(i)
487 except dbus.DBusException as e:482 except dbus.DBusException as e:
488 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':483 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
489 permission_denied_dialog(self.window_main)484 logging.error("Authentication canceled, changes have not been saved")
490485
491 def on_combobox_server_changed(self, combobox):486 def on_combobox_server_changed(self, combobox):
492 """487 """
@@ -515,7 +510,7 @@
515 self.backend.ChangeMainDownloadServer(uri)510 self.backend.ChangeMainDownloadServer(uri)
516 except dbus.DBusException as e:511 except dbus.DBusException as e:
517 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':512 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
518 permission_denied_dialog(self.window_main)513 logging.error("Authentication canceled, changes have not been saved")
519514
520 # mvo: is this still needed?515 # mvo: is this still needed?
521 #else:516 #else:
@@ -533,7 +528,7 @@
533 self.backend.DisableComponent(comp)528 self.backend.DisableComponent(comp)
534 except dbus.DBusException as e:529 except dbus.DBusException as e:
535 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':530 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
536 permission_denied_dialog(self.window_main)531 logging.error("Authentication canceled, changes have not been saved")
537532
538 def on_checkbutton_child_toggled(self, checkbutton, template):533 def on_checkbutton_child_toggled(self, checkbutton, template):
539 """534 """
@@ -546,7 +541,7 @@
546 self.backend.EnableChildSource(template.name)541 self.backend.EnableChildSource(template.name)
547 except dbus.DBusException as e:542 except dbus.DBusException as e:
548 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':543 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
549 permission_denied_dialog(self.window_main)544 logging.error("Authentication canceled, changes have not been saved")
550 545
551 def on_checkbutton_source_code_toggled(self, checkbutton):546 def on_checkbutton_source_code_toggled(self, checkbutton):
552 """ Disable or enable the source code for all sources """547 """ Disable or enable the source code for all sources """
@@ -557,7 +552,7 @@
557 self.backend.DisableSourceCodeSources()552 self.backend.DisableSourceCodeSources()
558 except dbus.DBusException as e:553 except dbus.DBusException as e:
559 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':554 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
560 permission_denied_dialog(self.window_main)555 logging.error("Authentication canceled, changes have not been saved")
561556
562 def on_checkbutton_popcon_toggled(self, widget):557 def on_checkbutton_popcon_toggled(self, widget):
563 """ The user clicked on the popcon paritipcation button """558 """ The user clicked on the popcon paritipcation button """
@@ -568,7 +563,7 @@
568 self.backend.SetPopconPariticipation(widget.get_active())563 self.backend.SetPopconPariticipation(widget.get_active())
569 except dbus.DBusException as e:564 except dbus.DBusException as e:
570 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':565 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
571 permission_denied_dialog(self.window_main)566 logging.error("Authentication canceled, changes have not been saved")
572567
573 def open_file(self, file):568 def open_file(self, file):
574 """Show a confirmation for adding the channels of the specified file"""569 """Show a confirmation for adding the channels of the specified file"""
@@ -587,7 +582,7 @@
587 self.backend.AddSourceFromLine(str(source))582 self.backend.AddSourceFromLine(str(source))
588 except dbus.DBusException as e:583 except dbus.DBusException as e:
589 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':584 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
590 permission_denied_dialog(self.window_main)585 logging.error("Authentication canceled, changes have not been saved")
591586
592 def on_sources_drag_data_received(self, widget, context, x, y,587 def on_sources_drag_data_received(self, widget, context, x, y,
593 selection, target_type, timestamp):588 selection, target_type, timestamp):
@@ -694,8 +689,7 @@
694 self.backend.ToggleSourceUse(str(source_entry))689 self.backend.ToggleSourceUse(str(source_entry))
695 except dbus.DBusException as e:690 except dbus.DBusException as e:
696 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':691 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
697 permission_denied_dialog(self.window_main)692 logging.error("Authentication canceled, changes have not been saved")
698
699 def init_keys(self):693 def init_keys(self):
700 """Setup the user interface parts needed for the key handling"""694 """Setup the user interface parts needed for the key handling"""
701 self.keys_store = Gtk.ListStore(str)695 self.keys_store = Gtk.ListStore(str)
@@ -753,7 +747,7 @@
753 self.backend.Revert()747 self.backend.Revert()
754 except dbus.DBusException as e:748 except dbus.DBusException as e:
755 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':749 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
756 permission_denied_dialog(self.window_main)750 logging.error("Authentication canceled, changes have not been saved")
757 if self.settings:751 if self.settings:
758 self.settings.set_int("regular-auto-launch-interval", self.initial_auto_launch)752 self.settings.set_int("regular-auto-launch-interval", self.initial_auto_launch)
759 self.show_auto_update_level()753 self.show_auto_update_level()
@@ -837,7 +831,7 @@
837 self.backend.SetUpdateInterval(value)831 self.backend.SetUpdateInterval(value)
838 except dbus.DBusException as e:832 except dbus.DBusException as e:
839 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':833 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
840 permission_denied_dialog(self.window_main)834 logging.error("Authentication canceled, changes have not been saved")
841835
842 def on_add_clicked(self, widget):836 def on_add_clicked(self, widget):
843 """Show a dialog that allows to enter the apt line of a to be used repo"""837 """Show a dialog that allows to enter the apt line of a to be used repo"""
@@ -849,7 +843,7 @@
849 self.backend.AddSourceFromLine(line)843 self.backend.AddSourceFromLine(line)
850 except dbus.DBusException as e:844 except dbus.DBusException as e:
851 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':845 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
852 permission_denied_dialog(self.window_main)846 logging.error("Authentication canceled, changes have not been saved")
853847
854 def on_edit_clicked(self, widget):848 def on_edit_clicked(self, widget):
855 """Show a dialog to edit an ISV source"""849 """Show a dialog to edit an ISV source"""
@@ -866,7 +860,7 @@
866 str(dialog.new_source_entry))860 str(dialog.new_source_entry))
867 except dbus.DBusException as e:861 except dbus.DBusException as e:
868 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':862 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
869 permission_denied_dialog(self.window_main)863 logging.error("Authentication canceled, changes have not been saved")
870864
871 # FIXME:outstanding from merge865 # FIXME:outstanding from merge
872 def on_isv_source_activated(self, treeview, path, column):866 def on_isv_source_activated(self, treeview, path, column):
@@ -907,7 +901,7 @@
907 self.backend.RemoveSource(str(source_entry))901 self.backend.RemoveSource(str(source_entry))
908 except dbus.DBusException as e:902 except dbus.DBusException as e:
909 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':903 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
910 permission_denied_dialog(self.window_main)904 logging.error("Authentication canceled, changes have not been saved")
911905
912 def add_key_clicked(self, widget):906 def add_key_clicked(self, widget):
913 """Provide a file chooser that allows to add the gnupg of a trusted907 """Provide a file chooser that allows to add the gnupg of a trusted
@@ -931,7 +925,7 @@
931 "or it might be corrupt."))925 "or it might be corrupt."))
932 except dbus.DBusException as e:926 except dbus.DBusException as e:
933 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':927 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
934 permission_denied_dialog(self.window_main)928 logging.error("Authentication canceled, changes have not been saved")
935929
936 def remove_key_clicked(self, widget):930 def remove_key_clicked(self, widget):
937 """Remove a trusted software vendor key"""931 """Remove a trusted software vendor key"""
@@ -948,7 +942,7 @@
948 "Please report this as a bug."))942 "Please report this as a bug."))
949 except dbus.DBusException as e:943 except dbus.DBusException as e:
950 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':944 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
951 permission_denied_dialog(self.window_main)945 logging.error("Authentication canceled, changes have not been saved")
952946
953 def on_restore_clicked(self, widget):947 def on_restore_clicked(self, widget):
954 """Restore the original keys"""948 """Restore the original keys"""
@@ -956,7 +950,7 @@
956 self.backend.UpdateKeys()950 self.backend.UpdateKeys()
957 except dbus.DBusException as e:951 except dbus.DBusException as e:
958 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':952 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
959 permission_denied_dialog(self.window_main)953 logging.error("Authentication canceled, changes have not been saved")
960954
961 def on_delete_event(self, widget, args):955 def on_delete_event(self, widget, args):
962 """Close the window if requested"""956 """Close the window if requested"""
@@ -978,7 +972,7 @@
978 self.backend.AddCdromSource()972 self.backend.AddCdromSource()
979 except dbus.DBusException as e:973 except dbus.DBusException as e:
980 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':974 if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy':
981 permission_denied_dialog(self.window_main) 975 logging.error("Authentication canceled, changes have not been saved")
982976
983 def on_driver_changes_progress(self, transaction, progress):977 def on_driver_changes_progress(self, transaction, progress):
984 #print(progress)978 #print(progress)

Subscribers

People subscribed via source and target branches

to status/vote changes: