def prefs_extension_add(self, url_params):
        url = url_params['query']['url']
        logger.info('Add extension: %s', url)
        downloader = ExtensionDownloader.get_instance()
        ext_id = downloader.download(url)
        ExtensionRunner.get_instance().run(ext_id)

        return self._get_all_extensions()
Exemplo n.º 2
0
 def test_run_all__run__called_with_extension_ids(self, mocker,
                                                  find_extensions):
     runner = ExtensionRunner()
     mocker.patch.object(runner, 'run')
     find_extensions.return_value = [('id_1', 'path_1'), ('id_2', 'path_2'),
                                     ('id_3', 'path_3')]
     runner.run_all()
     runner.run.assert_any_call('id_1')
     runner.run.assert_any_call('id_2')
     runner.run.assert_any_call('id_3')
    def prefs_extension_add(self, url_params):
        url = url_params['query']['url']
        logger.info('Add extension: %s' % url)
        downloader = ExtensionDownloader.get_instance()
        try:
            ext_id = downloader.download(url)
            ExtensionRunner.get_instance().run(ext_id)
        except (ExtensionDownloaderError, ManifestValidationError) as e:
            raise PrefsApiError(e.message)

        return self._get_all_extensions()
    def prefs_extension_add(self, url_params):
        url = url_params['query']['url']
        logger.info('Add extension: %s' % url)
        downloader = ExtensionDownloader.get_instance()
        try:
            ext_id = downloader.download(url)
            ExtensionRunner.get_instance().run(ext_id)
        except (ExtensionDownloaderError, ManifestValidationError) as e:
            raise PrefsApiError(e.message)

        return self._get_all_extensions()
Exemplo n.º 5
0
    def finish_initializing(self, builder):
        """Called while initializing this instance in __new__

        finish_initializing should be called after parsing the UI definition
        and creating a UlauncherWindow object with it in order to finish
        initializing the start of the new UlauncherWindow instance.
        """
        # Get a reference to the builder and set up the signals.
        self.builder = builder
        self.ui = builder.get_ui(self, True)
        self.PreferencesDialog = None  # class
        self.preferences_dialog = None  # instance

        self.results_nav = None
        self.window = self.ui['ulauncher_window']
        self.window_body = self.ui['body']
        self.input = self.ui['input']
        self.prefs_btn = self.ui['prefs_btn']
        self.result_box = self.ui["result_box"]

        self.input.connect('changed', self.on_input_changed)
        self.prefs_btn.connect('clicked', self.on_mnu_preferences_activate)

        self.set_keep_above(True)

        self.PreferencesDialog = PreferencesUlauncherDialog
        self.settings = Settings.get_instance()

        self.fix_window_width()
        self.position_window()
        self.init_theme()

        # this will trigger to show frequent apps if necessary
        self.show_results([])

        if not is_wayland_compatibility_on():
            # bind hotkey
            Keybinder.init()
            accel_name = self.settings.get_property('hotkey-show-app')
            # bind in the main thread
            GLib.idle_add(self.bind_show_app_hotkey, accel_name)

        start_app_watcher()
        ExtensionServer.get_instance().start()
        time.sleep(0.01)
        ExtensionRunner.get_instance().run_all()
        if not get_options().no_extensions:
            ExtensionDownloader.get_instance().download_missing()
 def _get_extension_info(self, ext_id: str, prefs: ExtensionPreferences, error: ExtError = None) -> ExtensionInfo:
     ext_db = ExtensionDb.get_instance()
     is_connected = True
     try:
         ExtensionServer.get_instance().get_controller(ext_id)
     except KeyError:
         is_connected = False
     ext_runner = ExtensionRunner.get_instance()
     is_running = is_connected or ext_runner.is_running(ext_id)
     ext_db_record = ext_db.find(ext_id, {})
     return {
         'id': ext_id,
         'url': ext_db_record.get('url'),
         'updated_at': ext_db_record.get('updated_at'),
         'last_commit': ext_db_record.get('last_commit'),
         'last_commit_time': ext_db_record.get('last_commit_time'),
         'name': prefs.manifest.get_name(),
         'icon': prefs.manifest.get_icon_path(),
         'description': prefs.manifest.get_description(),
         'developer_name': prefs.manifest.get_developer_name(),
         'preferences': prefs.get_items(),
         'error': error,
         'is_running': is_running,
         'runtime_error': ext_runner.get_extension_error(ext_id) if not is_running else None
     }
Exemplo n.º 7
0
    def finish_initializing(self, builder):
        """Called while initializing this instance in __new__

        finish_initializing should be called after parsing the UI definition
        and creating a UlauncherWindow object with it in order to finish
        initializing the start of the new UlauncherWindow instance.
        """
        # Get a reference to the builder and set up the signals.
        self.builder = builder
        self.ui = builder.get_ui(self, True)
        self.PreferencesDialog = None  # class
        self.preferences_dialog = None  # instance

        self.results_nav = None
        self.window = self.ui['ulauncher_window']
        self.input = self.ui['input']
        self.prefs_btn = self.ui['prefs_btn']
        self.result_box = self.ui["result_box"]

        self.input.connect('changed', self.on_input_changed)
        self.prefs_btn.connect('clicked', self.on_mnu_preferences_activate)

        self.set_keep_above(True)

        self.PreferencesDialog = PreferencesUlauncherDialog
        self.settings = Settings.get_instance()

        self.fix_window_width()
        self.position_window()
        self.init_theme()

        # this will trigger to show frequent apps if necessary
        self.show_results([])

        if not is_wayland_compatibility_on():
            # bind hotkey
            Keybinder.init()
            accel_name = self.settings.get_property('hotkey-show-app')
            # bind in the main thread
            GLib.idle_add(self.bind_show_app_hotkey, accel_name)

        start_app_watcher()
        ExtensionServer.get_instance().start()
        time.sleep(0.01)
        ExtensionRunner.get_instance().run_all()
        ExtensionDownloader.get_instance().download_missing()
Exemplo n.º 8
0
 def runner(self, ext_server):
     return ExtensionRunner(ext_server)
Exemplo n.º 9
0
 def get_instance(cls) -> 'ExtensionDownloader':
     ext_db = ExtensionDb.get_instance()
     ext_runner = ExtensionRunner.get_instance()
     return cls(ext_db, ext_runner)
Exemplo n.º 10
0
 def test_run__ExtensionManifest_open__is_called(self, ExtensionManifest):
     runner = ExtensionRunner()
     runner.run('id')
     ExtensionManifest.open.assert_called_with('id')
Exemplo n.º 11
0
 def test_run__incompatible_version__exception_is_raised(self, manifest):
     manifest.check_compatibility.side_effect = VersionIncompatibilityError(
     )
     runner = ExtensionRunner()
     with pytest.raises(VersionIncompatibilityError):
         runner.run('id')