From b5c37f6992810fd76d5e74989588517d66cba6f2 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Tue, 7 Apr 2015 15:05:23 +0000 Subject: [PATCH] move env to utility superclass so we don't need to override kwargs for it git-svn-id: https://xpra.org/svn/Xpra/trunk@8952 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/net/subprocess_wrapper.py | 15 ++++++++++++++- src/xpra/sound/wrapper.py | 24 ++++-------------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/xpra/net/subprocess_wrapper.py b/src/xpra/net/subprocess_wrapper.py index 2af42a6671..f0608ee250 100644 --- a/src/xpra/net/subprocess_wrapper.py +++ b/src/xpra/net/subprocess_wrapper.py @@ -261,7 +261,20 @@ def make_protocol(self): def exec_subprocess(self): kwargs = self.exec_kwargs() log("exec_subprocess() command=%s, kwargs=%s", self.command, kwargs) - return subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=sys.stderr.fileno(), **kwargs) + return subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=sys.stderr.fileno(), env=self.get_env(), **kwargs) + + def get_env(self): + env = os.environ.copy() + env["XPRA_SKIP_UI"] = "1" + env["XPRA_LOG_PREFIX"] = "%s " % self.description + #let's make things more complicated than they should be: + #on win32, the environment can end up containing unicode, and subprocess chokes on it + for k,v in env.items(): + try: + env[k] = bytestostr(v.encode("utf8")) + except: + env[k] = bytestostr(v) + return env def exec_kwargs(self): if os.name=="posix": diff --git a/src/xpra/sound/wrapper.py b/src/xpra/sound/wrapper.py index faf2eee3d4..fff3ecd13e 100644 --- a/src/xpra/sound/wrapper.py +++ b/src/xpra/sound/wrapper.py @@ -9,7 +9,6 @@ from xpra.net.subprocess_wrapper import subprocess_caller, subprocess_callee, gobject from xpra.platform.paths import get_sound_executable from xpra.util import AdHocStruct -from xpra.os_util import bytestostr from xpra.log import Logger log = Logger("sound") @@ -59,6 +58,7 @@ def start(self): def stop(self): wo = self.wrapped_object + log("stop() wrapped object=%s", wo) if wo: wo.cleanup() self.wrapped_object = None @@ -139,9 +139,8 @@ class sound_subprocess_wrapper(subprocess_caller): * handle "info" packets so we have a cached copy * forward get/set volume calls (get_volume uses the value found in "info") """ - def __init__(self, name): - subprocess_caller.__init__(self, description="sound") - self.name = name + def __init__(self, description): + subprocess_caller.__init__(self, description) self.state = "stopped" self.codec = "unknown" self.codec_description = "" @@ -150,22 +149,6 @@ def __init__(self, name): self.connect("state-changed", self.state_changed) self.connect("info", self.info_update) - def exec_kwargs(self): - #override so we can add the skip-ui flag needed for OSX to behave properly - kwargs = subprocess_caller.exec_kwargs(self) - env = os.environ.copy() - env["XPRA_SKIP_UI"] = "1" - env["XPRA_LOG_PREFIX"] = "%s " % self.name - kwargs["env"] = env - #let's make things more complicated than they should be: - #on win32, the environment can end up containing unicode, and subprocess chokes on it - for k,v in env.items(): - try: - env[k] = bytestostr(v.encode("utf8")) - except: - env[k] = bytestostr(v) - return kwargs - def state_changed(self, sink, new_state): self.state = new_state @@ -178,6 +161,7 @@ def get_info(self): return self.last_info def info_update(self, sink, info): + log("info_update(%s, %s)", sink, info) self.last_info = info self.last_info["time"] = int(time.time()) self.codec_description = info.get("codec_description")