[kupfer: 14/18] plugin top: fix for locales not using dot as decimal point.



commit dbd9ac837e3503703802e4d01da51a86b7eebb54
Author: Petr GajdÅÅek <gajdusek petr centrum cz>
Date:   Mon Jul 2 06:25:30 2012 +0200

    plugin top: fix for locales not using dot as decimal point.

 kupfer/plugin/top.py |    2 +-
 kupfer/utils.py      |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/top.py b/kupfer/plugin/top.py
index 169135a..d410cec 100644
--- a/kupfer/plugin/top.py
+++ b/kupfer/plugin/top.py
@@ -126,7 +126,7 @@ class TaskSource(Source, PicklingHelperMixin):
 	def _async_top_start(self):
 		uid = os.getuid()
 		utils.AsyncCommand(["top", "-b", "-n", "1", "-u", "%d" % uid],
-		                   self._async_top_finished, 60)
+		                   self._async_top_finished, 60, env=["LC_NUMERIC=C"])
 
 	def get_items(self):
 		for task in self._cache:
diff --git a/kupfer/utils.py b/kupfer/utils.py
index ed6632d..b845b12 100644
--- a/kupfer/utils.py
+++ b/kupfer/utils.py
@@ -96,6 +96,8 @@ class AsyncCommand (object):
 
 	If stdin is a byte string, it is supplied on the command's stdin.
 
+	If env is None, command will inherit the parent's environment.
+
 	finish_callback -> (AsyncCommand, stdout_output, stderr_output)
 
 	Attributes:
@@ -106,7 +108,7 @@ class AsyncCommand (object):
 	# the maximum input (bytes) we'll read in one shot (one io_callback)
 	max_input_buf = 512 * 1024
 
-	def __init__(self, argv, finish_callback, timeout_s, stdin=None):
+	def __init__(self, argv, finish_callback, timeout_s, stdin=None, env=None):
 		self.stdout = []
 		self.stderr = []
 		self.stdin = []
@@ -121,7 +123,7 @@ class AsyncCommand (object):
 		flags = (glib.SPAWN_SEARCH_PATH | glib.SPAWN_DO_NOT_REAP_CHILD)
 		pid, stdin_fd, stdout_fd, stderr_fd = \
 		     glib.spawn_async(argv, standard_output=True, standard_input=True,
-		                      standard_error=True, flags=flags)
+		                      standard_error=True, flags=flags, envp=env)
 
 		if stdin:
 			self.stdin[:] = self._split_string(stdin, self.max_input_buf)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]