Force C locale for pexpect for predictable output

This commit is contained in:
Sean Davis 2014-03-08 20:02:01 -05:00
parent 1facb03e34
commit cc8b57decb
2 changed files with 4 additions and 3 deletions

View File

@ -516,7 +516,8 @@ 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('%s %s %s' % (sudo, chfn, username))
# Force the C language for guaranteed english strings in the script.
child = pexpect.spawn('LANG=C %s %s %s' % (sudo, chfn, username))
child.timeout = 5
try:
child.expect([".*ssword.*", pexpect.EOF])
@ -537,7 +538,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('LANG=C %s' % chfn)
child.timeout = 5
try:
child.expect([".*ssword.*", pexpect.EOF])

View File

@ -216,7 +216,7 @@ class SudoDialog(Gtk.MessageDialog):
Return True if successful.
'''
# Set the pexpect variables and spawn the process.
child = pexpect.spawn('sudo /bin/true')
child = pexpect.spawn('LANG=C sudo /bin/true')
child.timeout = 1
try:
# Check for password prompt or program exit.