X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Futil%2Fexecfuncs.py;h=b25ae980724b5131951f6b4c427586d8e8ae0907;hb=35af1f1f8393dc9663b2a8be8a4c2b1d78f03bc1;hp=7e2d506d3050c5b9c2fe9232138e1f7d281566a1;hpb=eb111746f316ddd70f6eed77e432151c8ab96fe6;p=nepi.git
diff --git a/src/nepi/util/execfuncs.py b/src/nepi/util/execfuncs.py
index 7e2d506d..b25ae980 100644
--- a/src/nepi/util/execfuncs.py
+++ b/src/nepi/util/execfuncs.py
@@ -1,4 +1,23 @@
-from nepi.util.sshfuncs import RUNNING, FINISHED, NOT_STARTED, STDOUT
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+# Author: Alina Quereilhac
+
+from nepi.util.sshfuncs import ProcStatus, STDOUT
import subprocess
@@ -21,13 +40,14 @@ def lexec(command,
elif user:
command = "su %s ; %s " % (user, command)
+
p = subprocess.Popen(command,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
stdin = stdin)
out, err = p.communicate()
- return ((out, err), proc)
+ return (out, err)
def lcopy(source, dest, recursive = False):
"""
@@ -40,10 +60,17 @@ def lcopy(source, dest, recursive = False):
command = ["cp"]
if recursive:
command.append("-R")
-
- command.append(src)
- command.append(dst)
-
+
+ if isinstance(dest, str):
+ dest = dest.split(";")
+
+ if isinstance(src, str):
+ src = src.split(";")
+
+ args.extend(src)
+
+ args.extend(dest)
+
p = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
@@ -115,7 +142,7 @@ def lspawn(command, pidfile,
return (out,err),proc
-def lcheckpid(pidfile):
+def lgetpid(pidfile):
"""
Check the pidfile of a process spawned with remote_spawn.
@@ -160,14 +187,14 @@ def lstatus(pid, ppid):
})
if proc.wait():
- return NOT_STARTED
+ return ProcStatus.NOT_STARTED
status = False
if out:
status = (out.strip() == 'wait')
else:
- return NOT_STARTED
- return RUNNING if status else FINISHED
+ return ProcStatus.NOT_STARTED
+ return ProcStatus.RUNNING if status else ProcStatus.FINISHED
def lkill(pid, ppid, sudo = False):