Exemplo n.º 1
0
def spawn_local_handler():
    if hasattr(sys, 'pypy_objspaceclass'):
        python = 'python'
    else:
        python = sys.executable
    cmdline = '"%s" -u "%s" --stdio' % (python, GRAPHSERVER)
    child_in, child_out = os.popen2(cmdline, 'tb')
    io = msgstruct.FileIO(child_out, child_in)
    return io
Exemplo n.º 2
0
def spawn_local_handler():
    python = os.getenv('PYPY_PYGAME_PYTHON')
    if not python:
        python = sys.executable
    args = [python, '-u', GRAPHSERVER, '--stdio']
    p = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
    child_in, child_out = p.stdin, p.stdout
    io = msgstruct.FileIO(child_out, child_in)
    return io
Exemplo n.º 3
0
def spawn_local_handler():
    if hasattr(sys, 'pypy_objspaceclass'):
        python = 'python'
    else:
        python = sys.executable
    args = [python, '-u', GRAPHSERVER, '--stdio']
    p = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
    child_in, child_out = p.stdin, p.stdout
    io = msgstruct.FileIO(child_out, child_in)
    return io
Exemplo n.º 4
0
def spawn_local_handler():
    if hasattr(sys, 'pypy_objspaceclass'):
        # if 'python' is actually PyPy, e.g. in a virtualenv, then
        # try hard to find a real CPython
        try:
            python = subprocess.check_output(
                'env -i $SHELL -l -c "which python"', shell=True).strip()
        except subprocess.CalledProcessError:
            # did not work, fall back to 'python'
            python = 'python'
    else:
        python = sys.executable
    args = [python, '-u', GRAPHSERVER, '--stdio']
    p = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
    child_in, child_out = p.stdin, p.stdout
    io = msgstruct.FileIO(child_out, child_in)
    return io
Exemplo n.º 5
0
def copy_all(io1, io2):
    try:
        while True:
            io2.sendall(io1.recv())
    except EOFError:
        io2.close_sending()


if __name__ == '__main__':
    if len(sys.argv) != 2:
        print >> sys.stderr, __doc__
        sys.exit(2)
    if sys.argv[1] == '--stdio':
        # a one-shot server running on stdin/stdout
        io = msgstruct.FileIO(sys.stdin, sys.stdout)
        srv = Server(io)
        try:
            srv.run()
        except Exception, e:
            import traceback
            f = StringIO()
            traceback.print_exc(file=f)
            # try to add some explanations
            help = (" | if you want to debug on a remote machine, see\n"
                    " | instructions in dotviewer/sshgraphserver.py\n")
            try:
                import pygame
            except ImportError:
                f.seek(0)
                f.truncate()