Exemplo n.º 1
0
    def initialise(self, configure):
        logging.info("Initialising application")
        self.monitor = monitor.FileMonitor(self)
        self.configManager = cm.get_config_manager(self)
        self.service = service.Service(self)
        self.serviceDisabled = False

        # Initialise user code dir
        if self.configManager.userCodeDir is not None:
            sys.path.append(self.configManager.userCodeDir)

        try:
            self.service.start()
        except Exception as e:
            logging.exception("Error starting interface: " + str(e))
            self.serviceDisabled = True
            self.show_error_dialog(_("Error starting interface. Keyboard monitoring will be disabled.\n" +
                                    "Check your system/configuration."), str(e))

        self.notifier = get_notifier(self)
        self.configWindow = None
        self.monitor.start()

        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self.dbusService = common.AppService(self)

        if configure: self.show_configure()
Exemplo n.º 2
0
    def __init__(self, argv: list = sys.argv):
        super().__init__(argv)
        self.handler = CallbackEventHandler()
        parser = generate_argument_parser()
        self.args = parser.parse_args()
        try:
            self._create_storage_directories()
            self._configure_root_logger()
        except Exception as e:
            logging.exception("Fatal error starting AutoKey: " + str(e))
            self.show_error_dialog("Fatal error starting AutoKey.", str(e))
            sys.exit(1)
        logging.info("Initialising application")
        self.setWindowIcon(
            QIcon.fromTheme(common.ICON_FILE,
                            ui_common.load_icon(
                                ui_common.AutoKeyIcon.AUTOKEY)))
        try:

            # Initialise logger

            if self._verify_not_running():
                self._create_lock_file()

            self.monitor = monitor.FileMonitor(self)
            self.configManager = cm.get_config_manager(self)
            self.service = service.Service(self)
            self.serviceDisabled = False
            self._try_start_service()
            self.notifier = Notifier(self)
            self.configWindow = ConfigWindow(self)
            self.monitor.start()
            # Initialise user code dir
            if self.configManager.userCodeDir is not None:
                sys.path.append(self.configManager.userCodeDir)
            logging.debug("Creating DBus service")
            self.dbus_service = AppService(self)
            logging.debug("Service created")
            self.show_configure_signal.connect(self.show_configure,
                                               Qt.QueuedConnection)
            if cm.ConfigManager.SETTINGS[cm.IS_FIRST_RUN]:
                cm.ConfigManager.SETTINGS[cm.IS_FIRST_RUN] = False
                self.args.show_config_window = True
            if self.args.show_config_window:
                self.show_configure()

            self.installEventFilter(
                KeyboardChangeFilter(self.service.mediator.interface))

        except Exception as e:
            logging.exception("Fatal error starting AutoKey: " + str(e))
            self.show_error_dialog("Fatal error starting AutoKey.", str(e))
            sys.exit(1)
        else:
            sys.exit(self.exec_())