Fix pexpect crashes

This commit is contained in:
Sean Davis 2014-01-25 19:44:26 -05:00
parent da9ecfc678
commit 7438ea844c
3 changed files with 17 additions and 10 deletions

View File

@ -51,6 +51,7 @@ def which(command):
command.'''
command = subprocess.Popen(['which', command],
stdout=subprocess.PIPE).stdout.read().strip()
command = command.decode('utf-8')
if command == '':
logger.debug('Command "%s" could not be found.' % command)
return None
@ -445,6 +446,7 @@ class MugshotWindow(Window):
return return_codes
username = os.getenv('USER')
sudo = which('sudo')
chfn = which('chfn')
# Get each of the updated values.
@ -461,7 +463,7 @@ class MugshotWindow(Window):
# Full name can only be modified by root. Try using sudo to modify.
logger.debug('Attempting to set fullname with sudo chfn')
child = pexpect.spawn('sudo %s %s' % (chfn, username))
child = pexpect.spawn('%s %s %s' % (sudo, chfn, username))
child.timeout = 5
try:
child.expect([".*ssword.*", pexpect.EOF])
@ -482,7 +484,7 @@ class MugshotWindow(Window):
return_codes.append(child.exitstatus)
logger.debug('Attempting to set user details with chfn')
child = pexpect.spawn('chfn')
child = pexpect.spawn(chfn)
child.timeout = 5
try:
child.expect([".*ssword.*", pexpect.EOF])
@ -542,7 +544,10 @@ class MugshotWindow(Window):
logger.debug('Getting settings from %s' % prefs_file)
for line in open(prefs_file):
if "UserProfile/Data" in line:
value = line.split('<value>')[1].split('</value>')[0]
try:
value = line.split('<value>')[1].split('</value>')[0]
except IndexError:
continue
value = value.strip()
# First Name
if 'name="givenname"' in line:

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-25 18:39-0500\n"
"POT-Creation-Date: 2014-01-25 19:41-0500\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"
@ -148,18 +148,18 @@ msgstr ""
msgid "Retry"
msgstr ""
#: ../mugshot/MugshotWindow.py:374
#: ../mugshot/MugshotWindow.py:375
msgid "Update Pidgin buddy icon?"
msgstr ""
#: ../mugshot/MugshotWindow.py:375
#: ../mugshot/MugshotWindow.py:376
msgid "Would you also like to update your Pidgin buddy icon?"
msgstr ""
#: ../mugshot/MugshotWindow.py:578
#: ../mugshot/MugshotWindow.py:583
msgid "Update LibreOffice user details?"
msgstr ""
#: ../mugshot/MugshotWindow.py:579
#: ../mugshot/MugshotWindow.py:584
msgid "Would you also like to update your user details in LibreOffice?"
msgstr ""

View File

@ -81,7 +81,7 @@ def move_icon_file(root, target_data, prefix):
# Media is now empty
if len(os.listdir(old_icon_path)) == 0:
print(("Removing emptry directory: %s" % old_icon_path))
print(("Removing empty directory: %s" % old_icon_path))
os.rmdir(old_icon_path)
return icon_file
@ -180,6 +180,8 @@ DistUtilsExtra.auto.setup(
'to easily set profile image and user details for your '
'user profile and any supported applications.',
url='https://launchpad.net/mugshot',
data_files=[('share/man/man1', ['mugshot.1'])],
data_files=[('share/man/man1', ['mugshot.1']),
('share/glib-2.0/schemas', ['data/glib-2.0/schemas/'
'apps.mugshot.gschema.xml'])],
cmdclass={'install': InstallAndUpdateDataDirectory}
)