Exemplo n.º 1
0
def main() :
    try :
        nodeAddr = readAddr( sys.argv[1] )
    except :
        nodeAddr = ('208.78.96.185', 10001) # ('210.210.1.102',10001) 
    seedNodes = [nodeAddr]
    app = QApplication( sys.argv )
    icon = QIcon()
    for iconSize in [48,32,24,16] :
        icon.addPixmap( QPixmap(':/images/cspace%d.png'%iconSize) )
    app.setWindowIcon( icon )
    app.setQuitOnLastWindowClosed( False )
    reactor = Qt4Reactor()
    if not checkSettingsVersion() :
        return
    logFile = LogFile( localSettings() )
    sys.stdout = logFile
    sys.stderr = logFile
    logging.getLogger().addHandler( logging.StreamHandler() )
    initdelaygc( reactor )
    mainWin = MainWindow( seedNodes, reactor )
    mainWin.show()
    app.exec_()
    global execFileAfterExit
    if execFileAfterExit is not None :
        p = execFileAfterExit
        args = [p]
        startingDir = os.path.split( p )[0]
        spawnProcess( p, args, os.environ, startingDir, 0 )
Exemplo n.º 2
0
def main() :
    try :
        nodeAddr = readAddr( sys.argv[1] )
    except :
        nodeAddr = ('210.210.1.102',10001)
    seedNodes = [nodeAddr]
    app = QApplication( sys.argv )
    icon = QIcon()
    for iconSize in [48,32,24,16] :
        icon.addPixmap( QPixmap(':/images/cspace%d.png'%iconSize) )
    app.setWindowIcon( icon )
    app.setQuitOnLastWindowClosed( False )
    reactor = Qt4Reactor()
    if not checkSettingsVersion() :
        return
    logFile = LogFile( localSettings() )
    sys.stdout = logFile
    sys.stderr = logFile
    logging.getLogger().addHandler( logging.StreamHandler() )
    initdelaygc( reactor )
    mainWin = MainWindow( seedNodes, reactor )
    mainWin.show()
    app.exec_()
    global execFileAfterExit
    if execFileAfterExit is not None :
        p = execFileAfterExit
        args = [p]
        startingDir = os.path.split( p )[0]
        spawnProcess( p, args, os.environ, startingDir, 0 )
Exemplo n.º 3
0
 def _onConnectUser(self, err, sock):
     self.userConnectOp = None
     if err < 0:
         self.setText('Error connecting to %s' % env.contactName)
         return
     self.setText('Connected to %s' % env.contactName)
     self.connectedSock = sock
     self.listener = tcpListen(('127.0.0.1', 0), self.reactor,
                               self._onIncoming)
     listenPort = self.listener.getSock().getsockname()[1]
     vncViewer = os.path.join(os.path.split(sys.argv[0])[0], vncViewerPath)
     if vncViewerType == 'tightvnc':
         args = [vncViewer, '127.0.0.1::%d' % listenPort]
     elif vncViewerType == 'realvnc':
         if sys.platform == 'win32':
             args = [
                 vncViewer, 'AutoReconnect=0',
                 '127.0.0.1:%d' % listenPort
             ]
         else:
             args = [vncViewer, '127.0.0.1:%d' % listenPort]
     else:
         raise RuntimeError, "No suitable vnc viewer found"
     startingDir = os.path.split(vncViewer)[0]
     result = spawnProcess(vncViewer, args, os.environ, startingDir, 0)
     if not result:
         self.connectedSock.close()
         self.listener.close()
         self.setText('Error starting vncviewer: %s' % vncViewer)
         return
Exemplo n.º 4
0
 def _onConnectUser( self, err, sock ) :
     self.userConnectOp = None
     if err < 0 :
         self.setText( 'Error connecting to %s' % env.contactName )
         return
     self.setText( 'Connected to %s' % env.contactName )
     self.connectedSock = sock
     self.listener = tcpListen( ('127.0.0.1',0), self.reactor, self._onIncoming )
     listenPort = self.listener.getSock().getsockname()[1]
     vncViewer = os.path.join( os.path.split(sys.argv[0])[0], vncViewerPath )
     if vncViewerType == 'tightvnc' :
         args = [vncViewer, '127.0.0.1::%d' % listenPort ]
     elif vncViewerType == 'realvnc' :
         if sys.platform == 'win32' :
             args = [vncViewer, 'AutoReconnect=0', '127.0.0.1:%d' % listenPort ]
         else :
             args = [vncViewer, '127.0.0.1:%d' % listenPort ]
     else :
         raise RuntimeError, "No suitable vnc viewer found"
     startingDir = os.path.split( vncViewer )[0]
     result = spawnProcess( vncViewer, args, os.environ, startingDir, 0 )
     if not result :
         self.connectedSock.close()
         self.listener.close()
         self.setText( 'Error starting vncviewer: %s' % vncViewer )
         return
Exemplo n.º 5
0
 def _runCommand( self, command, envNew ) :
     env = dict( os.environ.items() )
     env.update( envNew )
     cmdLine = [_substituteMetaVars(x) for x in command]
     p = os.path.join( getAppDir(), cmdLine[0] )
     if not os.path.isfile(p) :
         p = self._findProgram( cmdLine[0] )
     args = [p] + cmdLine[1:]
     startingDir = os.getcwd()
     result = spawnProcess( p, args, env, startingDir, 0 )
     if not result :
         print 'error starting command (%s)' % p
Exemplo n.º 6
0
 def _onAccept( self, err, sock ) :
     if err < 0 :
         self.setText( 'Error in accepting connection from %s' % env.displayName )
         return
     self.peerSock = sock
     self.setText( 'Waiting for VNC Server to connect...' )
     self.listener = tcpListen( ('127.0.0.1',0), self.reactor, self._onIncoming )
     listenPort = self.listener.getSock().getsockname()[1]
     vncServer = os.path.join( os.path.split(sys.argv[0])[0], vncServerPath )
     args = [vncServer]
     environ = dict( os.environ.items() )
     environ['VNC_SERVER_PORT'] = str(listenPort)
     startingDir = os.path.split( vncServer )[0]
     result = spawnProcess( vncServer, args, environ, startingDir, 0 )
     if not result :
         self.peerSock.close()
         self.listener.close()
         self.setText( 'Error starting vnc server: %s' % vncServer )
         return
Exemplo n.º 7
0
 def _onAccept(self, err, sock):
     if err < 0:
         self.setText('Error in accepting connection from %s' %
                      env.displayName)
         return
     self.peerSock = sock
     self.setText('Waiting for VNC Server to connect...')
     self.listener = tcpListen(('127.0.0.1', 0), self.reactor,
                               self._onIncoming)
     listenPort = self.listener.getSock().getsockname()[1]
     vncServer = os.path.join(os.path.split(sys.argv[0])[0], vncServerPath)
     args = [vncServer]
     environ = dict(os.environ.items())
     environ['VNC_SERVER_PORT'] = str(listenPort)
     startingDir = os.path.split(vncServer)[0]
     result = spawnProcess(vncServer, args, environ, startingDir, 0)
     if not result:
         self.peerSock.close()
         self.listener.close()
         self.setText('Error starting vnc server: %s' % vncServer)
         return