示例#1
0
    def startApplication(self, first_start=True):
        self.m_server = QLocalServer()
        if self.m_server.listen(self.sock_file):
            if "--testnet" in sys.argv[1:]:
                print("Starting app... TESTNET MODE")
            else:
                print("Starting app...")
            self.appMain.run()
        else:
            if not first_start:
                print("Error listening the socket. App can't start!",
                      file=sys.stderr)
                QTimer.singleShot(250, self.quit)
                return

            # remove the listener path file and try to restart app one more time
            print("Error listening the socket. Try to restart application...",
                  file=sys.stderr)
            if sys.platform != 'win32':
                try:
                    os.unlink(self.sock_file)
                except Exception, err:
                    print(err, file=sys.stderr)

            QTimer.singleShot(250,
                              lambda: self.startApplication(first_start=False))
 def startApplication(self):
     self.m_server = QLocalServer()
     print "startApplication() function from QSingleApplication got called"
     # Returns bool (True on success). Tells server to listen for incoming connections on 'name'
     if self.m_server.listen(self.applicationName()):
         print "Server is listening .... startApplication() function from QSingleApp"
         self.m_server.newConnection.connect(self.getNewConnection)
         # After emitting a signal, connecting it to the UI class function
         self.argsReceived.connect(self.mainWindow.receive_args)
         self.mainWindow.show()
     else:
         QMessageBox.critical(None, self.tr("Error"),
                              self.tr("Error listening the socket."))
示例#3
0
 def createStatusBar(self):
     """
     Create the status bar.
     """
     statusbar = self.statusBar
     # line and column number
     self.lineColNumber = QLabel(statusbar)
     self.lineColNumber.setText("")
     statusbar.addPermanentWidget(self.lineColNumber)
     statusbar.socketServer = QLocalServer()
     statusbar.socketServer.removeServer(self.infolog.socket)
     statusbar.socketServer.listen(self.infolog.socket)
     statusbar.socketServer.newConnection.connect(
         self.setupStatusConnection)
     self.log.info('Ready')
示例#4
0
    def _create_server(self, try_remove=True):
        """
        Attempt to create a new local server and start listening.
        """
        if not self._server:
            self._server = QLocalServer(self)
            self._server.newConnection.connect(self._new_connection)

        if self._server.isListening():
            return True

        # If desired, remove the old server file.
        if try_remove:
            QLocalServer.removeServer(self._app_id)

        # Now, attempt to listen and return the success of that.
        return self._server.listen(self._app_id)
示例#5
0
 def _createServer(self):
     from PySide.QtNetwork import QLocalServer
     ret = QLocalServer(self.q)
     ret.newConnection.connect(self._onNewConnection)
     return ret