Esempio n. 1
0
def main():
    if detect_stub():
        from solipsis.node import main as node_main
        node_main.main()
        sys.exit(0)
    params = build_params()
    # If an URL has been specified, try to connect to a running navigator
    if params.url_jump:
        filename = os.path.join('state', 'url_jump.port')
        try:
            f = file(filename, 'rb')
            url_port = int(f.read())
            f.close()
        except (IOError, EOFError, ValueError):
            pass
        else:
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            try:
                s.connect(('127.0.0.1', url_port))
            except socket.error:
                pass
            else:
                s.send(params.url_jump + '\r\n')
                s.close()
                sys.exit(0)

    application = NavigatorApp(redirect=False,
                               params=params)
    try:
        application.MainLoop()
    except (SystemExit, KeyboardInterrupt):
        pass
    sys.exit(0)
#!/usr/bin/env python

import os
import os.path
import sys

if __name__ == '__main__':
    # Adjust path
    current_file = sys.argv[0]
    current_path = os.path.normcase(os.path.dirname(os.path.abspath(current_file)))
    os.chdir(current_path)
    if not current_path in sys.path:
        sys.path.insert(0, current_path)
    # Launch
    from solipsis.node import main
    main.main()