try:
msg = self.recv_msg(conn)
except socket.timeout, e:
- self.log_error("SERVER recv_msg: connection timedout ")
+ #self.log_error("SERVER recv_msg: connection timedout ")
continue
if not msg:
# Wait for the forwarder to be ready, otherwise nobody
# will be able to connect to it
- helo = self._process.stderr.readline()
- if helo != 'FORWARDER_READY.\n':
- raise AssertionError, "Expected 'FORWARDER_READY.', got %r: %s" % (helo,
- helo + self._process.stderr.read())
+ err = []
+ helo = "nope"
+ while helo:
+ helo = self._process.stderr.readline()
+ if helo == 'FORWARDER_READY.\n':
+ break
+ err.append(helo)
+ else:
+ raise AssertionError, "Expected 'FORWARDER_READY.', got: %s" % (''.join(err),)
def send_msg(self, msg):
encoded = base64.b64encode(msg)
shell = False
cmd = ""
- if sudo:
- cmd +="sudo "
if python_path:
python_path.replace("'", r"'\''")
cmd = """PYTHONPATH="$PYTHONPATH":'%s' """ % python_path
#cmd += "$CMD "
#cmd += "strace -f -tt -s 200 -o strace$$.out "
import nepi
- cmd += "python -c 'import sys; sys.path.append(%s); from nepi.util import server; server.decode_and_execute()'" % (
+ cmd += "python -c 'import sys; sys.path.insert(0,%s); from nepi.util import server; server.decode_and_execute()'" % (
repr(os.path.dirname(os.path.dirname(nepi.__file__))).replace("'",'"'),
)
+ if sudo:
+ if ';' in cmd:
+ cmd = "sudo bash -c " + shell_escape(cmd)
+ else:
+ cmd = "sudo " + cmd
+
if communication == DC.ACCESS_SSH:
tmp_known_hosts = None
args = ['ssh',
server_key, host, port, args)
args.append(cmd)
else:
- args = [cmd]
+ args = cmd
shell = True
# connects to the remote host and starts a remote