Exemplo n.º 1
0
        lArgIndex = 1
    while lArgIndex < len(argv) and argv[lArgIndex][-3:] != '.py':
        lNodePortValues.append(argv[lArgIndex])
        lArgIndex += 1
    masterNet.setNodePortValues(lNodePortValues)
    if '--help' in argv or '-h' in argv:  # show help
        masterNet.helpForNetworkAsApplication()
    elif '-w' in argv:  # run without Vision and exit
        # create communicator
        from NetworkEditor.net import Communicator
        masterNet.communicator = Communicator(masterNet)
        print 'Communicator listening on port:', masterNet.communicator.port

        import socket
        f = open(argv[0] + '.sock', 'w')
        f.write("%s %i" % (socket.gethostbyname(
            socket.gethostname()), masterNet.communicator.port))
        f.close()

        masterNet.run()

    else:  # stand alone application while vision is hidden
        if '-e' in argv:  # run and exit
            masterNet.run()
        elif '-r' in argv or len(
                masterNet.userPanels) == 0:  # no user panel => run
            masterNet.run()
            mainLoopVisionToRunNetworkAsApplication(masterNet.editor)
        else:  # user panel
            mainLoopVisionToRunNetworkAsApplication(masterNet.editor)
        import socket
        f = open(argv[0]+'.sock', 'w')
        f.write("%s %i"%(socket.gethostbyname(socket.gethostname()),
                         masterNet.communicator.port))
        f.close()

        # create communication socket
        import socket
        HOST = ''                 # Symbolic name meaning the local host
        PORT = 50010              # Arbitrary non-privileged port
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.bind((HOST, PORT))
        s.listen(5)
        s.setblocking(0)
        masterNet.socket = s
        masterNet.socketConnections = []
        masterNet.HOST = HOST
        masterNet.PORT = PORT

        masterNet.run()

    else: # stand alone application while vision is hidden
        if '-e' in argv: # run and exit
            masterNet.run()
        elif '-r' in argv or len(masterNet.userPanels) == 0: # no user panel => run
            masterNet.run()
            mainLoopVisionToRunNetworkAsApplication(masterNet.editor)
        else: # user panel
            mainLoopVisionToRunNetworkAsApplication(masterNet.editor)