示例#1
0
文件: main.py 项目: duniter/sakia
def main():
    # activate ctrl-c interrupt
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    sakia = QApplication(sys.argv)

    sys.excepthook = exception_handler

    #sakia.setStyle('Fusion')
    loop = QSelectorEventLoop(sakia)
    loop.set_exception_handler(async_exception_handler)
    #loop.set_debug(True)
    asyncio.set_event_loop(loop)

    with loop:
        app = Application.startup(sys.argv, sakia, loop)

        lock = single_instance_lock(app.currency)
        if not lock:
            lock = single_instance_lock(app.currency)
            if not lock:
                QMessageBox.critical(None, "Sakia",
                                 "Sakia is already running.")

                sys.exit(1)
        app.start_coroutines()
        app.get_last_version()
        keep_trying = True
        while not app.blockchain_service.initialized():
            try:
                box = QMessageBox()
                box.setWindowTitle("Initialization")
                box.setText("Connecting to the network...")
                wFlags = box.windowFlags()
                if Qt.WindowCloseButtonHint == (wFlags & Qt.WindowCloseButtonHint):
                    wFlags = wFlags ^ Qt.WindowCloseButtonHint
                    box.setWindowFlags(wFlags)
                box.show()
                loop.run_until_complete(app.initialize_blockchain())
                box.hide()
            except (DuniterError, NoPeerAvailable) as e:
                reply = QMessageBox.critical(None, "Error", "Error connecting to the network : {:}. Keep Trying ?".format(str(e)),
                                             QMessageBox.Ok | QMessageBox.Abort)
                if reply == QMessageBox.Ok:
                    loop.run_until_complete(PreferencesDialog(app).async_exec())
                else:
                    break
        else:
            if not app.connection_exists():
                conn_controller = ConnectionConfigController.create_connection(None, app)
                loop.run_until_complete(conn_controller.async_exec())
            window = MainWindowController.startup(app)
            loop.run_forever()
        try:
            loop.set_exception_handler(exit_exception_handler)
            loop.run_until_complete(app.stop_current_profile())
            logging.debug("Application stopped")
        except asyncio.CancelledError:
            logging.info('CancelledError')
    logging.debug("Exiting")
    cleanup_lock(lock)
    sys.exit()
示例#2
0
def main():
    # activate ctrl-c interrupt
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    sakia = QApplication(sys.argv)

    sys.excepthook = exception_handler

    sakia.setStyle('Fusion')
    loop = QSelectorEventLoop(sakia)
    loop.set_exception_handler(async_exception_handler)
    #loop.set_debug(True)
    asyncio.set_event_loop(loop)

    with loop:
        app = Application.startup(sys.argv, sakia, loop)

        lock = single_instance_lock(app.currency)
        if not lock:
            lock = single_instance_lock(app.currency)
            if not lock:
                QMessageBox.critical(None, "Sakia",
                                     "Sakia is already running.")

                sys.exit(1)
        app.start_coroutines()
        app.get_last_version()
        keep_trying = True
        while not app.blockchain_service.initialized():
            try:
                box = QMessageBox()
                box.setWindowTitle("Initialization")
                box.setText("Connecting to the network...")
                wFlags = box.windowFlags()
                if Qt.WindowCloseButtonHint == (wFlags
                                                & Qt.WindowCloseButtonHint):
                    wFlags = wFlags ^ Qt.WindowCloseButtonHint
                    box.setWindowFlags(wFlags)
                box.show()
                loop.run_until_complete(app.initialize_blockchain())
                box.hide()
            except (DuniterError, NoPeerAvailable) as e:
                reply = QMessageBox.critical(
                    None, "Error",
                    "Error connecting to the network : {:}. Keep Trying ?".
                    format(str(e)), QMessageBox.Ok | QMessageBox.Abort)
                if reply == QMessageBox.Ok:
                    loop.run_until_complete(
                        PreferencesDialog(app).async_exec())
                else:
                    break
        else:
            if not app.connection_exists():
                conn_controller = ConnectionConfigController.create_connection(
                    None, app)
                loop.run_until_complete(conn_controller.async_exec())
            window = MainWindowController.startup(app)
            loop.run_forever()
        try:
            loop.set_exception_handler(None)
            loop.run_until_complete(app.stop_current_profile())
            logging.debug("Application stopped")
        except asyncio.CancelledError:
            logging.info('CancelledError')
    logging.debug("Exiting")
    cleanup_lock(lock)
    sys.exit()
示例#3
0
文件: main.py 项目: arkryonia/sakia
        QMessageBox.Critical, "Critical error",
        """A critical error occured. Select the details to display it.
                  Please report it to <a href='https://github.com/duniter/sakia/issues/new/'>the developers github</a>""",
        QMessageBox.Ok, QApplication.activeWindow())
    mb.setDetailedText(message)
    mb.setTextFormat(Qt.RichText)

    mb.exec()


if __name__ == '__main__':
    # activate ctrl-c interrupt
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    sakia = QApplication(sys.argv)

    lock = single_instance_lock()
    if not lock:
        lock = single_instance_lock()
        if not lock:
            QMessageBox.critical(None, "Sakia", "Sakia is already running.")

            sys.exit(1)

    sys.excepthook = exception_handler

    sakia.setStyle('Fusion')
    loop = QSelectorEventLoop(sakia)
    loop.set_exception_handler(async_exception_handler)
    asyncio.set_event_loop(loop)

    with loop: