X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Flinux%2Fnode.py;h=0410b16b15bed4e1ab5055721d5118a0201f5854;hb=5d80869516dfcecb8e7fe6f117e2fb658b57b25b;hp=5080a6c4e63453ce3160a692b41b376b9b61faa8;hpb=87f44a7c2853afb7021276dd3700858cff950703;p=nepi.git diff --git a/src/nepi/resources/linux/node.py b/src/nepi/resources/linux/node.py index 5080a6c4..0410b16b 100644 --- a/src/nepi/resources/linux/node.py +++ b/src/nepi/resources/linux/node.py @@ -336,7 +336,7 @@ class LinuxNode(ResourceManager): # Node needs to wait until all associated interfaces are # ready before it can finalize deployment from nepi.resources.linux.interface import LinuxInterface - ifaces = self.get_connected(LinuxInterface.rtype()) + ifaces = self.get_connected(LinuxInterface) for iface in ifaces: if iface.state < ResourceState.READY: self.ec.schedule(reschedule_delay, self.deploy) @@ -754,18 +754,19 @@ class LinuxNode(ResourceManager): # wait until command finishes to execute self.wait_run(pid, ppid) - (out, err), proc = self.check_errors(home, + (eout, err), proc = self.check_errors(home, ecodefile = ecodefile, - stdout = stdout, - stderr= stderr) + stderr = stderr) # Out is what was written in the stderr file if err: msg = " Failed to run command '%s' " % command - self.error(msg, out, err) + self.error(msg, eout, err) if raise_on_error: raise RuntimeError, msg + + (out, oerr), proc = self.check_output(home, stdout) return (out, err), proc @@ -818,8 +819,8 @@ class LinuxNode(ResourceManager): return self.upload(command, shfile, text = True, overwrite = overwrite) def format_environment(self, env, inline = False): - """Format environmental variables for command to be executed either - as an inline command + """ Formats the environment variables for a command to be executed + either as an inline command (i.e. export PYTHONPATH=src/..; export LALAL= ..;python script.py) or as a bash script (i.e. export PYTHONPATH=src/.. \n export LALA=.. \n) """ @@ -833,18 +834,14 @@ class LinuxNode(ResourceManager): def check_errors(self, home, ecodefile = "exitcode", - stdout = "stdout", stderr = "stderr"): - """ - Checks whether errors occurred while running a command. + """ Checks whether errors occurred while running a command. It first checks the exit code for the command, and only if the exit code is an error one it returns the error output. """ proc = None err = "" - # retrive standard output from the file - (out, oerr), oproc = self.check_output(home, stdout) # get exit code saved in the 'exitcode' file ecode = self.exitcode(home, ecodefile) @@ -862,7 +859,7 @@ class LinuxNode(ResourceManager): if ecode == ExitCode.FILENOTFOUND and proc.poll() == 1: err = "" - return (out, err), proc + return ("", err), proc def wait_pid(self, home, pidfile = "pidfile", raise_on_error = False): """ Waits until the pid file for the command is generated,