Python

Program futtatása és az utolsó sor kivételével mind továbbítása

line = None last_line = None process = subprocess.Popen(["bash", "-c", "echo 111; echo 222 >&2; echo 333; echo -e '444\n\n'; sleep 3; echo 555; echo 666; exit 66"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while not line == b'': if last_line is not None: sys.stdout.buffer.write(last_line) last_line = line line = process.stdout.readline() result = {"exit_code": process.wait(), "last_line": last_line}

Távoli debuggolás

PyDevd mappa felmásolása a cél gépre:

scp -r "${HOME}/.eclipse/org.eclipse.platform_4.3.2_1473617060_linux_gtk_x86_64/plugins/org.python.pydev_3.4.1.201403181715/pysrc" root@gep:"/opt/pydevd"

Debug kód:

import sys sys.path.append('/opt/pydevd') import pydevd pydevd.settrace('eclipse_ip', stdoutToServer=True, stderrToServer=True)