Fix potential crash if missing AccountsService permissions

This commit is contained in:
Sean Davis 2014-04-04 21:21:19 -04:00
parent 4ac8066158
commit c814911d96
3 changed files with 39 additions and 37 deletions

View File

@ -458,27 +458,30 @@ class MugshotWindow(Window):
def accounts_service_set_user_image(self, filename):
"""Set user profile image using AccountsService."""
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
result = bus.call_sync('org.freedesktop.Accounts',
'/org/freedesktop/Accounts',
'org.freedesktop.Accounts',
'FindUserByName',
GLib.Variant('(s)', (username,)),
GLib.VariantType.new('(o)'),
Gio.DBusCallFlags.NONE,
-1,
None)
(path,) = result.unpack()
try:
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
result = bus.call_sync('org.freedesktop.Accounts',
'/org/freedesktop/Accounts',
'org.freedesktop.Accounts',
'FindUserByName',
GLib.Variant('(s)', (username,)),
GLib.VariantType.new('(o)'),
Gio.DBusCallFlags.NONE,
-1,
None)
(path,) = result.unpack()
bus.call_sync('org.freedesktop.Accounts',
path,
'org.freedesktop.Accounts.User',
'SetIconFile',
GLib.Variant('(s)', (filename,)),
GLib.VariantType.new('()'),
Gio.DBusCallFlags.NONE,
-1,
None)
bus.call_sync('org.freedesktop.Accounts',
path,
'org.freedesktop.Accounts.User',
'SetIconFile',
GLib.Variant('(s)', (filename,)),
GLib.VariantType.new('()'),
Gio.DBusCallFlags.NONE,
-1,
None)
except GLib.GError:
pass
def set_pidgin_buddyicon(self, filename=None):
"""Sets the pidgin buddyicon to filename (usually ~/.face).

View File

@ -34,7 +34,6 @@ def check_sudo():
return False
except:
child.close()
print("Sudoer")
return True

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-01 23:14-0400\n"
"POT-Creation-Date: 2014-04-04 21:20-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -61,7 +61,7 @@ msgstr ""
msgid "Browse…"
msgstr ""
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:571
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:573
msgid "Mugshot"
msgstr ""
@ -131,65 +131,65 @@ msgid "Retry"
msgstr ""
#. Password was incorrect, complain.
#: ../mugshot/MugshotWindow.py:328
#: ../mugshot/MugshotWindow.py:327
msgid "Authentication Failed"
msgstr ""
#: ../mugshot/MugshotWindow.py:329
#: ../mugshot/MugshotWindow.py:328
msgid "User details were not updated."
msgstr ""
#: ../mugshot/MugshotWindow.py:493
#: ../mugshot/MugshotWindow.py:495
msgid "Update Pidgin buddy icon?"
msgstr ""
#: ../mugshot/MugshotWindow.py:494
#: ../mugshot/MugshotWindow.py:496
msgid "Would you also like to update your Pidgin buddy icon?"
msgstr ""
#: ../mugshot/MugshotWindow.py:572
#: ../mugshot/MugshotWindow.py:574
msgid "Enter your password to change user details."
msgstr ""
#: ../mugshot/MugshotWindow.py:574
#: ../mugshot/MugshotWindow.py:576
msgid ""
"This is a security measure to prevent unwanted updates\n"
"to your personal information."
msgstr ""
#: ../mugshot/MugshotWindow.py:725
#: ../mugshot/MugshotWindow.py:727
msgid "Update LibreOffice user details?"
msgstr ""
#: ../mugshot/MugshotWindow.py:726
#: ../mugshot/MugshotWindow.py:728
msgid "Would you also like to update your user details in LibreOffice?"
msgstr ""
#: ../mugshot_lib/SudoDialog.py:80
#: ../mugshot_lib/SudoDialog.py:79
msgid "Cancel"
msgstr ""
#: ../mugshot_lib/SudoDialog.py:81
#: ../mugshot_lib/SudoDialog.py:80
msgid "OK"
msgstr ""
#: ../mugshot_lib/SudoDialog.py:94
#: ../mugshot_lib/SudoDialog.py:93
msgid ""
"Enter your password to\n"
"perform administrative tasks."
msgstr ""
#: ../mugshot_lib/SudoDialog.py:96
#: ../mugshot_lib/SudoDialog.py:95
#, python-format
msgid ""
"The application '%s' lets you\n"
"modify essential parts of your system."
msgstr ""
#: ../mugshot_lib/SudoDialog.py:117
#: ../mugshot_lib/SudoDialog.py:116
msgid "Incorrect password... try again."
msgstr ""
#: ../mugshot_lib/SudoDialog.py:122
#: ../mugshot_lib/SudoDialog.py:121
msgid "Password:"
msgstr ""