[PATCH 22/22] Add an option to startProgram to not reset the locale
David Shea
dshea at redhat.com
Wed Jun 3 16:03:46 UTC 2015
For the interactive programs started by anaconda, keep the locale set by
the user.
(cherry picked from commit 1c8391e19357f842d904d54bd7e6ef8fab01f0b4)
Related: rhbz#1188287
---
pyanaconda/ihelp.py | 2 +-
pyanaconda/iutil.py | 12 +++++++-----
pyanaconda/ui/gui/spokes/network.py | 4 ++--
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/pyanaconda/ihelp.py b/pyanaconda/ihelp.py
index 5326048..470f300 100644
--- a/pyanaconda/ihelp.py
+++ b/pyanaconda/ihelp.py
@@ -124,7 +124,7 @@ def start_yelp(help_path):
# under some extreme circumstances (placeholders missing)
# the help path can be None and we need to prevent Popen
# receiving None as an argument instead of a string
- yelp_process = startProgram(["yelp", help_path or ""])
+ yelp_process = startProgram(["yelp", help_path or ""], reset_lang=False)
def kill_yelp():
"""Try to kill any existing yelp processes"""
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py
index 51525cb..8391a6d 100644
--- a/pyanaconda/iutil.py
+++ b/pyanaconda/iutil.py
@@ -63,9 +63,7 @@ def setenv(name, value):
def augmentEnv():
env = os.environ.copy()
- env.update({"LC_ALL": "C",
- "ANA_INSTALL_PATH": getSysroot()
- })
+ env.update({"ANA_INSTALL_PATH": getSysroot()})
env.update(_child_env)
return env
@@ -114,7 +112,7 @@ def setSysroot(path):
_sysroot = path
def startProgram(argv, root='/', stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- env_prune=None, env_add=None, reset_handlers=True, **kwargs):
+ env_prune=None, env_add=None, reset_handlers=True, reset_lang=True, **kwargs):
""" Start an external program and return the Popen object.
The root and reset_handlers arguments are handled by passing a
@@ -130,6 +128,7 @@ def startProgram(argv, root='/', stdin=None, stdout=subprocess.PIPE, stderr=subp
:param env_prune: environment variables to remove before execution
:param env_add: environment variables to add before execution
:param reset_handlers: whether to reset to SIG_DFL any signal handlers set to SIG_IGN
+ :param reset_lang: whether to set the locale of the child process to C
:param kwargs: Additional parameters to pass to subprocess.Popen
:return: A Popen object for the running command.
"""
@@ -170,6 +169,9 @@ def startProgram(argv, root='/', stdin=None, stdout=subprocess.PIPE, stderr=subp
for var in env_prune:
env.pop(var, None)
+ if reset_lang:
+ env.update({"LC_ALL": "C"})
+
if env_add:
env.update(env_add)
@@ -404,7 +406,7 @@ def execReadlines(command, argv, stdin=None, root='/', env_prune=None):
## Run a shell.
def execConsole():
try:
- proc = startProgram(["/bin/sh"], stdout=None, stderr=None)
+ proc = startProgram(["/bin/sh"], stdout=None, stderr=None, reset_lang=False)
proc.wait()
except OSError as e:
raise RuntimeError("Error running /bin/sh: " + e.strerror)
diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 6c51e23..a89001f 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -558,7 +558,7 @@ class NetworkControlBox(GObject.GObject):
log.info("network: configuring connection %s device %s ssid %s",
uuid, devname, self.selected_ssid)
self.kill_nmce(msg="Configure button clicked")
- proc = startProgram(["nm-connection-editor", "--edit", "%s" % uuid])
+ proc = startProgram(["nm-connection-editor", "--edit", "%s" % uuid], reset_lang=False)
self._running_nmce = proc
GLib.child_watch_add(proc.pid, self.on_nmce_exited, activate)
@@ -648,7 +648,7 @@ class NetworkControlBox(GObject.GObject):
def add_device(self, ty):
log.info("network: adding device of type %s", ty)
self.kill_nmce(msg="Add device button clicked")
- proc = startProgram(["nm-connection-editor", "--create", "--type=%s" % ty])
+ proc = startProgram(["nm-connection-editor", "--create", "--type=%s" % ty], reset_lang=False)
self._running_nmce = proc
GLib.child_watch_add(proc.pid, self.on_nmce_exited)
--
2.1.0
More information about the anaconda-patches
mailing list