From cc8b57decbf2545e798dd9ed65e47c4abb6da7f5 Mon Sep 17 00:00:00 2001 From: Sean Davis Date: Sat, 8 Mar 2014 20:02:01 -0500 Subject: [PATCH] Force C locale for pexpect for predictable output --- mugshot/MugshotWindow.py | 5 +++-- mugshot_lib/SudoDialog.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mugshot/MugshotWindow.py b/mugshot/MugshotWindow.py index a4c43f2..ddb83e9 100644 --- a/mugshot/MugshotWindow.py +++ b/mugshot/MugshotWindow.py @@ -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]) diff --git a/mugshot_lib/SudoDialog.py b/mugshot_lib/SudoDialog.py index 5f15d6e..5f9c113 100644 --- a/mugshot_lib/SudoDialog.py +++ b/mugshot_lib/SudoDialog.py @@ -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.