Exemplo n.º 1
0
    def on_close(self, framer):
        """
        Terminates extension process on client disconnect.

        Triggers :class:`~ulauncher.api.shared.event.SystemExitEvent` for graceful shutdown

        :param ulauncher.utils.framer.PickleFramer framer:
        """
        logger.warning("Connection closed. Exiting")
        self.extension.trigger_event(SystemExitEvent())
        # extension has 0.5 sec to save it's state, after that it will be terminated
        timer(0.5, partial(os._exit, 0))
Exemplo n.º 2
0
    def stop(self, extension_id):
        """
        Terminates extension
        """
        if self.is_running(extension_id):
            logger.info('Terminating extension "%s"', extension_id)
            extproc = self.extension_procs[extension_id]
            self.extension_procs.pop(extension_id, None)

            extproc.subprocess.send_signal(signal.SIGTERM)

            timer(0.5, partial(self.confirm_termination, extproc))
Exemplo n.º 3
0
    def stop(self, extension_id):
        """
        Terminates extension
        """
        if not self.is_running(extension_id):
            raise ExtensionIsNotRunningError(f"Extension ID: {extension_id}")

        logger.info('Terminating extension "%s"', extension_id)
        extproc = self.extension_procs[extension_id]
        self.extension_procs.pop(extension_id, None)

        extproc.subprocess.send_signal(signal.SIGTERM)

        timer(0.5, partial(self.confirm_termination, extproc))
Exemplo n.º 4
0
        def debounced(*args, **kwargs):
            def call_it():
                fn(*args, **kwargs)

            try:
                debounced.t.cancel()
            except AttributeError:
                pass

            debounced.t = timer(wait, call_it)
Exemplo n.º 5
0
 def test_timer_second(self, GLib):
     func = mock.Mock()
     seconds_time = 2
     ctx = timer(seconds_time, func)
     GLib.timeout_source_new_seconds.assert_called_with(seconds_time)
     src = ctx.source
     ctx.trigger(None)
     func.assert_called_once()
     ctx.cancel()
     src.destroy.assert_called_once()
Exemplo n.º 6
0
    def handle_event(self, event, controller):
        """
        Schedules "Loading..." message

        :rtype: :class:`~ulauncher.api.shared.action.DoNothingAction.DoNothingAction`
        """
        icon = controller.get_manifest().get_icon_path()
        loading_message = Result(name='Loading...', icon=icon)

        self._cancel_loading()
        self.loading = timer(self.LOADING_DELAY,
                             RenderResultListAction([loading_message]).run)
        self.active_event = event
        self.active_controller = controller

        return DoNothingAction()
Exemplo n.º 7
0
 def on_focus_out(self, widget, event):
     # apparently Gtk doesn't provide a mechanism to tell if window is in focus
     # this is a simple workaround to avoid hiding window
     # when user hits Alt+key combination or changes input source, etc.
     self.is_focused = False
     timer(0.07, lambda: self.is_focused or self.hide())