Merge lp:~evfool/software-properties/lp1058072 into lp:software-properties
- lp1058072
- Merge into main
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Didier Roche-Tolomelli | Approve | ||
Review via email: mp+135760@code.launchpad.net |
Commit message
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.
- 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 | 33 | import subprocess | 33 | import subprocess |
6 | 34 | from aptdaemon import client | 34 | from aptdaemon import client |
7 | 35 | from aptdaemon.errors import NotAuthorizedError, TransactionFailed | 35 | from aptdaemon.errors import NotAuthorizedError, TransactionFailed |
8 | 36 | import logging | ||
9 | 36 | 37 | ||
10 | 37 | from gi.repository import GObject, Gdk, Gtk, Gio | 38 | from gi.repository import GObject, Gdk, Gtk, Gio |
11 | 38 | 39 | ||
12 | @@ -81,12 +82,6 @@ | |||
13 | 81 | dialog.destroy() | 82 | dialog.destroy() |
14 | 82 | return False | 83 | return False |
15 | 83 | 84 | ||
16 | 84 | # using this often, so defining it here. | ||
17 | 85 | def permission_denied_dialog(parent_window): | ||
18 | 86 | error(parent_window, | ||
19 | 87 | _("Authorization failed."), | ||
20 | 88 | _("Software sources can't be changed without permission.")) | ||
21 | 89 | |||
22 | 90 | class SoftwarePropertiesGtk(SoftwareProperties,SimpleGtkbuilderApp): | 85 | class SoftwarePropertiesGtk(SoftwareProperties,SimpleGtkbuilderApp): |
23 | 91 | 86 | ||
24 | 92 | def __init__(self, datadir=None, options=None, file=None, parent=None): | 87 | def __init__(self, datadir=None, options=None, file=None, parent=None): |
25 | @@ -464,7 +459,7 @@ | |||
26 | 464 | self.backend.SetUpdateAutomationLevel(state) | 459 | self.backend.SetUpdateAutomationLevel(state) |
27 | 465 | except dbus.DBusException as e: | 460 | except dbus.DBusException as e: |
28 | 466 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 461 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
30 | 467 | permission_denied_dialog(self.window_main) | 462 | logging.error("Authentication canceled, changes have not been saved") |
31 | 468 | 463 | ||
32 | 469 | def set_other_update_automation_level(self, widget): | 464 | def set_other_update_automation_level(self, widget): |
33 | 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""" |
34 | @@ -486,7 +481,7 @@ | |||
35 | 486 | self.backend.SetReleaseUpgradesPolicy(i) | 481 | self.backend.SetReleaseUpgradesPolicy(i) |
36 | 487 | except dbus.DBusException as e: | 482 | except dbus.DBusException as e: |
37 | 488 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 483 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
39 | 489 | permission_denied_dialog(self.window_main) | 484 | logging.error("Authentication canceled, changes have not been saved") |
40 | 490 | 485 | ||
41 | 491 | def on_combobox_server_changed(self, combobox): | 486 | def on_combobox_server_changed(self, combobox): |
42 | 492 | """ | 487 | """ |
43 | @@ -515,7 +510,7 @@ | |||
44 | 515 | self.backend.ChangeMainDownloadServer(uri) | 510 | self.backend.ChangeMainDownloadServer(uri) |
45 | 516 | except dbus.DBusException as e: | 511 | except dbus.DBusException as e: |
46 | 517 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 512 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
48 | 518 | permission_denied_dialog(self.window_main) | 513 | logging.error("Authentication canceled, changes have not been saved") |
49 | 519 | 514 | ||
50 | 520 | # mvo: is this still needed? | 515 | # mvo: is this still needed? |
51 | 521 | #else: | 516 | #else: |
52 | @@ -533,7 +528,7 @@ | |||
53 | 533 | self.backend.DisableComponent(comp) | 528 | self.backend.DisableComponent(comp) |
54 | 534 | except dbus.DBusException as e: | 529 | except dbus.DBusException as e: |
55 | 535 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 530 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
57 | 536 | permission_denied_dialog(self.window_main) | 531 | logging.error("Authentication canceled, changes have not been saved") |
58 | 537 | 532 | ||
59 | 538 | def on_checkbutton_child_toggled(self, checkbutton, template): | 533 | def on_checkbutton_child_toggled(self, checkbutton, template): |
60 | 539 | """ | 534 | """ |
61 | @@ -546,7 +541,7 @@ | |||
62 | 546 | self.backend.EnableChildSource(template.name) | 541 | self.backend.EnableChildSource(template.name) |
63 | 547 | except dbus.DBusException as e: | 542 | except dbus.DBusException as e: |
64 | 548 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 543 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
66 | 549 | permission_denied_dialog(self.window_main) | 544 | logging.error("Authentication canceled, changes have not been saved") |
67 | 550 | 545 | ||
68 | 551 | def on_checkbutton_source_code_toggled(self, checkbutton): | 546 | def on_checkbutton_source_code_toggled(self, checkbutton): |
69 | 552 | """ Disable or enable the source code for all sources """ | 547 | """ Disable or enable the source code for all sources """ |
70 | @@ -557,7 +552,7 @@ | |||
71 | 557 | self.backend.DisableSourceCodeSources() | 552 | self.backend.DisableSourceCodeSources() |
72 | 558 | except dbus.DBusException as e: | 553 | except dbus.DBusException as e: |
73 | 559 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 554 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
75 | 560 | permission_denied_dialog(self.window_main) | 555 | logging.error("Authentication canceled, changes have not been saved") |
76 | 561 | 556 | ||
77 | 562 | def on_checkbutton_popcon_toggled(self, widget): | 557 | def on_checkbutton_popcon_toggled(self, widget): |
78 | 563 | """ The user clicked on the popcon paritipcation button """ | 558 | """ The user clicked on the popcon paritipcation button """ |
79 | @@ -568,7 +563,7 @@ | |||
80 | 568 | self.backend.SetPopconPariticipation(widget.get_active()) | 563 | self.backend.SetPopconPariticipation(widget.get_active()) |
81 | 569 | except dbus.DBusException as e: | 564 | except dbus.DBusException as e: |
82 | 570 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 565 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
84 | 571 | permission_denied_dialog(self.window_main) | 566 | logging.error("Authentication canceled, changes have not been saved") |
85 | 572 | 567 | ||
86 | 573 | def open_file(self, file): | 568 | def open_file(self, file): |
87 | 574 | """Show a confirmation for adding the channels of the specified file""" | 569 | """Show a confirmation for adding the channels of the specified file""" |
88 | @@ -587,7 +582,7 @@ | |||
89 | 587 | self.backend.AddSourceFromLine(str(source)) | 582 | self.backend.AddSourceFromLine(str(source)) |
90 | 588 | except dbus.DBusException as e: | 583 | except dbus.DBusException as e: |
91 | 589 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 584 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
93 | 590 | permission_denied_dialog(self.window_main) | 585 | logging.error("Authentication canceled, changes have not been saved") |
94 | 591 | 586 | ||
95 | 592 | def on_sources_drag_data_received(self, widget, context, x, y, | 587 | def on_sources_drag_data_received(self, widget, context, x, y, |
96 | 593 | selection, target_type, timestamp): | 588 | selection, target_type, timestamp): |
97 | @@ -694,8 +689,7 @@ | |||
98 | 694 | self.backend.ToggleSourceUse(str(source_entry)) | 689 | self.backend.ToggleSourceUse(str(source_entry)) |
99 | 695 | except dbus.DBusException as e: | 690 | except dbus.DBusException as e: |
100 | 696 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 691 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
103 | 697 | permission_denied_dialog(self.window_main) | 692 | logging.error("Authentication canceled, changes have not been saved") |
102 | 698 | |||
104 | 699 | def init_keys(self): | 693 | def init_keys(self): |
105 | 700 | """Setup the user interface parts needed for the key handling""" | 694 | """Setup the user interface parts needed for the key handling""" |
106 | 701 | self.keys_store = Gtk.ListStore(str) | 695 | self.keys_store = Gtk.ListStore(str) |
107 | @@ -753,7 +747,7 @@ | |||
108 | 753 | self.backend.Revert() | 747 | self.backend.Revert() |
109 | 754 | except dbus.DBusException as e: | 748 | except dbus.DBusException as e: |
110 | 755 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 749 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
112 | 756 | permission_denied_dialog(self.window_main) | 750 | logging.error("Authentication canceled, changes have not been saved") |
113 | 757 | if self.settings: | 751 | if self.settings: |
114 | 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) |
115 | 759 | self.show_auto_update_level() | 753 | self.show_auto_update_level() |
116 | @@ -837,7 +831,7 @@ | |||
117 | 837 | self.backend.SetUpdateInterval(value) | 831 | self.backend.SetUpdateInterval(value) |
118 | 838 | except dbus.DBusException as e: | 832 | except dbus.DBusException as e: |
119 | 839 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 833 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
121 | 840 | permission_denied_dialog(self.window_main) | 834 | logging.error("Authentication canceled, changes have not been saved") |
122 | 841 | 835 | ||
123 | 842 | def on_add_clicked(self, widget): | 836 | def on_add_clicked(self, widget): |
124 | 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""" |
125 | @@ -849,7 +843,7 @@ | |||
126 | 849 | self.backend.AddSourceFromLine(line) | 843 | self.backend.AddSourceFromLine(line) |
127 | 850 | except dbus.DBusException as e: | 844 | except dbus.DBusException as e: |
128 | 851 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 845 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
130 | 852 | permission_denied_dialog(self.window_main) | 846 | logging.error("Authentication canceled, changes have not been saved") |
131 | 853 | 847 | ||
132 | 854 | def on_edit_clicked(self, widget): | 848 | def on_edit_clicked(self, widget): |
133 | 855 | """Show a dialog to edit an ISV source""" | 849 | """Show a dialog to edit an ISV source""" |
134 | @@ -866,7 +860,7 @@ | |||
135 | 866 | str(dialog.new_source_entry)) | 860 | str(dialog.new_source_entry)) |
136 | 867 | except dbus.DBusException as e: | 861 | except dbus.DBusException as e: |
137 | 868 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 862 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
139 | 869 | permission_denied_dialog(self.window_main) | 863 | logging.error("Authentication canceled, changes have not been saved") |
140 | 870 | 864 | ||
141 | 871 | # FIXME:outstanding from merge | 865 | # FIXME:outstanding from merge |
142 | 872 | def on_isv_source_activated(self, treeview, path, column): | 866 | def on_isv_source_activated(self, treeview, path, column): |
143 | @@ -907,7 +901,7 @@ | |||
144 | 907 | self.backend.RemoveSource(str(source_entry)) | 901 | self.backend.RemoveSource(str(source_entry)) |
145 | 908 | except dbus.DBusException as e: | 902 | except dbus.DBusException as e: |
146 | 909 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 903 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
148 | 910 | permission_denied_dialog(self.window_main) | 904 | logging.error("Authentication canceled, changes have not been saved") |
149 | 911 | 905 | ||
150 | 912 | def add_key_clicked(self, widget): | 906 | def add_key_clicked(self, widget): |
151 | 913 | """Provide a file chooser that allows to add the gnupg of a trusted | 907 | """Provide a file chooser that allows to add the gnupg of a trusted |
152 | @@ -931,7 +925,7 @@ | |||
153 | 931 | "or it might be corrupt.")) | 925 | "or it might be corrupt.")) |
154 | 932 | except dbus.DBusException as e: | 926 | except dbus.DBusException as e: |
155 | 933 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 927 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
157 | 934 | permission_denied_dialog(self.window_main) | 928 | logging.error("Authentication canceled, changes have not been saved") |
158 | 935 | 929 | ||
159 | 936 | def remove_key_clicked(self, widget): | 930 | def remove_key_clicked(self, widget): |
160 | 937 | """Remove a trusted software vendor key""" | 931 | """Remove a trusted software vendor key""" |
161 | @@ -948,7 +942,7 @@ | |||
162 | 948 | "Please report this as a bug.")) | 942 | "Please report this as a bug.")) |
163 | 949 | except dbus.DBusException as e: | 943 | except dbus.DBusException as e: |
164 | 950 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 944 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
166 | 951 | permission_denied_dialog(self.window_main) | 945 | logging.error("Authentication canceled, changes have not been saved") |
167 | 952 | 946 | ||
168 | 953 | def on_restore_clicked(self, widget): | 947 | def on_restore_clicked(self, widget): |
169 | 954 | """Restore the original keys""" | 948 | """Restore the original keys""" |
170 | @@ -956,7 +950,7 @@ | |||
171 | 956 | self.backend.UpdateKeys() | 950 | self.backend.UpdateKeys() |
172 | 957 | except dbus.DBusException as e: | 951 | except dbus.DBusException as e: |
173 | 958 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 952 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
175 | 959 | permission_denied_dialog(self.window_main) | 953 | logging.error("Authentication canceled, changes have not been saved") |
176 | 960 | 954 | ||
177 | 961 | def on_delete_event(self, widget, args): | 955 | def on_delete_event(self, widget, args): |
178 | 962 | """Close the window if requested""" | 956 | """Close the window if requested""" |
179 | @@ -978,7 +972,7 @@ | |||
180 | 978 | self.backend.AddCdromSource() | 972 | self.backend.AddCdromSource() |
181 | 979 | except dbus.DBusException as e: | 973 | except dbus.DBusException as e: |
182 | 980 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': | 974 | if e._dbus_error_name == 'com.ubuntu.SoftwareProperties.PermissionDeniedByPolicy': |
184 | 981 | permission_denied_dialog(self.window_main) | 975 | logging.error("Authentication canceled, changes have not been saved") |
185 | 982 | 976 | ||
186 | 983 | def on_driver_changes_progress(self, transaction, progress): | 977 | def on_driver_changes_progress(self, transaction, progress): |
187 | 984 | #print(progress) | 978 | #print(progress) |
I would prefer that instead of a totally silently failing, that we log something on stderr. What do you think?