git://git.onelab.eu
/
nepi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Trying to make LinuxNS3Simulator to deploy remotely ....
[nepi.git]
/
src
/
nepi
/
util
/
execfuncs.py
diff --git
a/src/nepi/util/execfuncs.py
b/src/nepi/util/execfuncs.py
index
e09d490
..
98b9d73
100644
(file)
--- a/
src/nepi/util/execfuncs.py
+++ b/
src/nepi/util/execfuncs.py
@@
-24,7
+24,6
@@
import subprocess
def lexec(command,
user = None,
sudo = False,
def lexec(command,
user = None,
sudo = False,
- stdin = None,
env = None):
"""
Executes a local command, returns ((stdout,stderr),process)
env = None):
"""
Executes a local command, returns ((stdout,stderr),process)
@@
-41,13
+40,12
@@
def lexec(command,
command = "su %s ; %s " % (user, command)
command = "su %s ; %s " % (user, command)
- p = subprocess.Popen(command, shell=True,
+ p
roc
= subprocess.Popen(command, shell=True,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
- #stdin = stdin)
- out, err = p.communicate()
- return (
out, err
)
+ out, err = p
roc
.communicate()
+ return (
(out, err), proc
)
def lcopy(source, dest, recursive = False):
"""
def lcopy(source, dest, recursive = False):
"""
@@
-64,7
+62,7
@@
def lcopy(source, dest, recursive = False):
command.append(src)
command.append(dst)
command.append(src)
command.append(dst)
- p = subprocess.Popen(command,
+ p
roc
= subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
@@
-128,12
+126,12
@@
def lspawn(command, pidfile,
'create' : 'mkdir -p %s ; ' % (shell_escape(home),) if create_home else '',
}
'create' : 'mkdir -p %s ; ' % (shell_escape(home),) if create_home else '',
}
- (out,err),proc = lexec(cmd)
+ (out,err),
proc = lexec(cmd)
if proc.wait():
raise RuntimeError, "Failed to set up application on host %s: %s %s" % (host, out,err,)
if proc.wait():
raise RuntimeError, "Failed to set up application on host %s: %s %s" % (host, out,err,)
- return (
out,err),proc
+ return (
(out,err), proc)
def lgetpid(pidfile):
"""
def lgetpid(pidfile):
"""
@@
-148,7
+146,7
@@
def lgetpid(pidfile):
or None if the pidfile isn't valid yet (maybe the process is still starting).
"""
or None if the pidfile isn't valid yet (maybe the process is still starting).
"""
- (out,err),proc = lexec("cat %s" % pidfile )
+ (out,err),
proc = lexec("cat %s" % pidfile )
if proc.wait():
return None
if proc.wait():
return None
@@
-172,7
+170,7
@@
def lstatus(pid, ppid):
One of NOT_STARTED, RUNNING, FINISHED
"""
One of NOT_STARTED, RUNNING, FINISHED
"""
- (out,err),proc = lexec(
+ (out,err),
proc = lexec(
# Check only by pid. pid+ppid does not always work (especially with sudo)
" (( ps --pid %(pid)d -o pid | grep -c %(pid)d && echo 'wait') || echo 'done' ) | tail -n 1" % {
'ppid' : ppid,
# Check only by pid. pid+ppid does not always work (especially with sudo)
" (( ps --pid %(pid)d -o pid | grep -c %(pid)d && echo 'wait') || echo 'done' ) | tail -n 1" % {
'ppid' : ppid,
@@
-187,8
+185,8
@@
def lstatus(pid, ppid):
status = (out.strip() == 'wait')
else:
return ProcStatus.NOT_STARTED
status = (out.strip() == 'wait')
else:
return ProcStatus.NOT_STARTED
+
return ProcStatus.RUNNING if status else ProcStatus.FINISHED
return ProcStatus.RUNNING if status else ProcStatus.FINISHED
-
def lkill(pid, ppid, sudo = False):
"""
def lkill(pid, ppid, sudo = False):
"""