1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-30 18:32:28 +01:00

Make client survive the daemon going down.

Port a few fixes from trunk.
This commit is contained in:
Dan O'Reilly
2008-12-14 18:31:24 -05:00
parent 41c975a22a
commit ab7b331aac
4 changed files with 81 additions and 43 deletions

View File

@@ -69,7 +69,7 @@ def Run(cmd, include_stderr=False, return_pipe=False):
one output string from the command.
"""
if type(cmd) is not list:
if not isinstance(cmd, list):
cmd = to_unicode(str(cmd))
cmd = cmd.split()
if include_stderr:
@@ -82,8 +82,12 @@ def Run(cmd, include_stderr=False, return_pipe=False):
tmpenv = os.environ.copy()
tmpenv["LC_ALL"] = "C"
tmpenv["LANG"] = "C"
f = Popen(cmd, shell=False, stdout=PIPE, stderr=err, close_fds=fds, cwd='/',
env=tmpenv)
try:
f = Popen(cmd, shell=False, stdout=PIPE, stderr=err, close_fds=fds,
cwd='/', env=tmpenv)
except OSError, e:
print "Running command %s failed: %s" % (str(cmd), str(e))
return ""
if return_pipe:
return f.stdout
@@ -383,7 +387,7 @@ def find_path(cmd):
the file can not be found.
"""
paths = os.getenv("PATH", default=["/usr/bin", "/usr/local/bin"]).split(':')
paths = os.getenv("PATH", default="/usr/bin:/usr/local/bin").split(':')
for path in paths:
if os.access(os.path.join(path, cmd), os.F_OK):
return os.path.join(path, cmd)