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:
12
wicd/misc.py
12
wicd/misc.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user