From bdc3111790ba4d21c89914c182fd6f532f16ad75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Gajd=C5=AF=C5=A1ek?= Date: Mon, 2 Jul 2012 06:25:30 +0200 Subject: [PATCH 2/2] 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) -- 1.7.10