Fix pexpect crashes
This commit is contained in:
parent
da9ecfc678
commit
7438ea844c
|
@ -51,6 +51,7 @@ def which(command):
|
||||||
command.'''
|
command.'''
|
||||||
command = subprocess.Popen(['which', command],
|
command = subprocess.Popen(['which', command],
|
||||||
stdout=subprocess.PIPE).stdout.read().strip()
|
stdout=subprocess.PIPE).stdout.read().strip()
|
||||||
|
command = command.decode('utf-8')
|
||||||
if command == '':
|
if command == '':
|
||||||
logger.debug('Command "%s" could not be found.' % command)
|
logger.debug('Command "%s" could not be found.' % command)
|
||||||
return None
|
return None
|
||||||
|
@ -445,6 +446,7 @@ class MugshotWindow(Window):
|
||||||
return return_codes
|
return return_codes
|
||||||
|
|
||||||
username = os.getenv('USER')
|
username = os.getenv('USER')
|
||||||
|
sudo = which('sudo')
|
||||||
chfn = which('chfn')
|
chfn = which('chfn')
|
||||||
|
|
||||||
# Get each of the updated values.
|
# 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.
|
# Full name can only be modified by root. Try using sudo to modify.
|
||||||
logger.debug('Attempting to set fullname with sudo chfn')
|
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
|
child.timeout = 5
|
||||||
try:
|
try:
|
||||||
child.expect([".*ssword.*", pexpect.EOF])
|
child.expect([".*ssword.*", pexpect.EOF])
|
||||||
|
@ -482,7 +484,7 @@ class MugshotWindow(Window):
|
||||||
return_codes.append(child.exitstatus)
|
return_codes.append(child.exitstatus)
|
||||||
|
|
||||||
logger.debug('Attempting to set user details with chfn')
|
logger.debug('Attempting to set user details with chfn')
|
||||||
child = pexpect.spawn('chfn')
|
child = pexpect.spawn(chfn)
|
||||||
child.timeout = 5
|
child.timeout = 5
|
||||||
try:
|
try:
|
||||||
child.expect([".*ssword.*", pexpect.EOF])
|
child.expect([".*ssword.*", pexpect.EOF])
|
||||||
|
@ -542,7 +544,10 @@ class MugshotWindow(Window):
|
||||||
logger.debug('Getting settings from %s' % prefs_file)
|
logger.debug('Getting settings from %s' % prefs_file)
|
||||||
for line in open(prefs_file):
|
for line in open(prefs_file):
|
||||||
if "UserProfile/Data" in line:
|
if "UserProfile/Data" in line:
|
||||||
|
try:
|
||||||
value = line.split('<value>')[1].split('</value>')[0]
|
value = line.split('<value>')[1].split('</value>')[0]
|
||||||
|
except IndexError:
|
||||||
|
continue
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
# First Name
|
# First Name
|
||||||
if 'name="givenname"' in line:
|
if 'name="givenname"' in line:
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -148,18 +148,18 @@ msgstr ""
|
||||||
msgid "Retry"
|
msgid "Retry"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:374
|
#: ../mugshot/MugshotWindow.py:375
|
||||||
msgid "Update Pidgin buddy icon?"
|
msgid "Update Pidgin buddy icon?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:375
|
#: ../mugshot/MugshotWindow.py:376
|
||||||
msgid "Would you also like to update your Pidgin buddy icon?"
|
msgid "Would you also like to update your Pidgin buddy icon?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:578
|
#: ../mugshot/MugshotWindow.py:583
|
||||||
msgid "Update LibreOffice user details?"
|
msgid "Update LibreOffice user details?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:579
|
#: ../mugshot/MugshotWindow.py:584
|
||||||
msgid "Would you also like to update your user details in LibreOffice?"
|
msgid "Would you also like to update your user details in LibreOffice?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
6
setup.py
6
setup.py
|
@ -81,7 +81,7 @@ def move_icon_file(root, target_data, prefix):
|
||||||
|
|
||||||
# Media is now empty
|
# Media is now empty
|
||||||
if len(os.listdir(old_icon_path)) == 0:
|
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)
|
os.rmdir(old_icon_path)
|
||||||
|
|
||||||
return icon_file
|
return icon_file
|
||||||
|
@ -180,6 +180,8 @@ DistUtilsExtra.auto.setup(
|
||||||
'to easily set profile image and user details for your '
|
'to easily set profile image and user details for your '
|
||||||
'user profile and any supported applications.',
|
'user profile and any supported applications.',
|
||||||
url='https://launchpad.net/mugshot',
|
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}
|
cmdclass={'install': InstallAndUpdateDataDirectory}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue