Skip to content

Commit

Permalink
move env to utility superclass so we don't need to override kwargs fo…
Browse files Browse the repository at this point in the history
…r it

git-svn-id: https://xpra.org/svn/Xpra/trunk@8952 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 7, 2015
1 parent c292b1f commit b5c37f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
15 changes: 14 additions & 1 deletion src/xpra/net/subprocess_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
24 changes: 4 additions & 20 deletions src/xpra/sound/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = ""
Expand All @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit b5c37f6

Please sign in to comment.