self.kill()
def run(self):
- dst = os.path.join(self.app_home, "app.ssh")
+ dst = os.path.join(self.app_home, "app.sh")
# Create shell script with the command
# This way, complex commands and scripts can be ran seamlessly
cmd += self.command
self.node.upload(cmd, dst)
- cmd = "bash ./app.sh",
- self.node.run(cmd, self.app_home)
+ command = 'bash ./app.sh'
+ stdin = 'stdin' if self.stdin else None
+ self.node.run(command, self.app_home, stdin = stdin)
self.pid, self.ppid = self.node.checkpid(self.app_home)
def status(self):
from neco.execution.resource import Resource
-from neco.util.sshfuncs import eintr_retry, shell_escape, rexec, rcopy, \
+from neco.util.sshfuncs import eintr_retry, rexec, rcopy, \
rspawn, rcheck_pid, rstatus, rkill, RUNNING
import cStringIO
def mkdir(self, path, clean = True):
if clean:
self.execute(
- "rm -f %s" % shell_escape(path),
+ "rm -rf %s" % path,
timeout = 120,
retry = 3
)
self.execute(
- "mkdir -p %s" % shell_escape(path),
+ "mkdir -p %s" % path,
timeout = 120,
retry = 3
)
def run(self, command, home,
- stdin = 'stdin',
+ stdin = None,
stdout = 'stdout',
stderr = 'stderr',
sudo = False):
command = "sudo " + command
args.append(command)
- print " ".join(args)
-
for x in xrange(retry or 3):
# connects to the remote host and starts a remote connection
proc = subprocess.Popen(args,
args.extend(('-i', identity_file))
if isinstance(source, file) or hasattr(source, 'read'):
- args.append('cat > %s' % (shell_escape(dest),))
+ args.append('cat > %s' % dest)
elif isinstance(dest, file) or hasattr(dest, 'write'):
- args.append('cat %s' % (shell_escape(dest),))
+ args.append('cat %s' % dest)
else:
raise AssertionError, "Unreachable code reached! :-Q"
daemon_command = '{ { %(command)s > %(stdout)s 2>%(stderr)s < %(stdin)s & } ; echo $! 1 > %(pidfile)s ; }' % {
'command' : command,
- 'pidfile' : shell_escape(pidfile),
+ 'pidfile' : pidfile,
'stdout' : stdout,
'stderr' : stderr,
'stdin' : stdin,
}
- cmd = "%(create)s%(gohome)s rm -f %(pidfile)s ; %(sudo)s nohup bash -c %(command)s " % {
- 'command' : shell_escape(daemon_command),
+ cmd = "%(create)s%(gohome)s rm -f %(pidfile)s ; %(sudo)s nohup bash -c '%(command)s' " % {
+ 'command' : daemon_command,
'sudo' : 'sudo -S' if sudo else '',
- 'pidfile' : shell_escape(pidfile),
- 'gohome' : 'cd %s ; ' % (shell_escape(home),) if home else '',
- 'create' : 'mkdir -p %s ; ' % (shell_escape,) if create_home else '',
+ 'pidfile' : pidfile,
+ 'gohome' : 'cd %s ; ' % home if home else '',
+ 'create' : 'mkdir -p %s ; ' % home if create_home else '',
}
(out,err), proc = rexec(