Пример #1
0
 def run_all(self):
     """
     Finds all extensions in `EXTENSIONS_DIR` and runs them
     """
     for ex_id, _ in find_extensions(EXTENSIONS_DIR):
         try:
             self.run(ex_id)
         # pylint: disable=broad-except
         except Exception as e:
             logger.error("Couldn't run '%s'. %s: %s", ex_id,
                          type(e).__name__, e)
Пример #2
0
    def download_missing(self) -> None:
        already_downloaded = {id for id, _ in find_extensions(EXTENSIONS_DIR)}
        for id, ext in self.ext_db.get_records().items():
            if id in already_downloaded:
                continue

            logger.info('Downloading missing extension %s', id)
            try:
                ext_id = self.download(ext['url'])
                self.ext_runner.run(ext_id)
            # pylint: disable=broad-except
            except Exception as e:
                logger.error('%s: %s', type(e).__name__, e)
Пример #3
0
    def _get_all_extensions(self) -> List[ExtensionInfo]:
        extensions = []
        for ext_id, _ in find_extensions(EXTENSIONS_DIR):
            prefs = ExtensionPreferences.create_instance(ext_id)  # type: ExtensionPreferences
            prefs.manifest.refresh()
            error = None
            try:
                prefs.manifest.validate()
                prefs.manifest.check_compatibility()
            except UlauncherAPIError as e:
                error = cast(ExtError, {
                    'message': str(e),
                    'errorName': e.error_name
                })
            except Exception as e:
                error = cast(ExtError, {
                    'message': str(e),
                    'errorName': ErrorName.UnexpectedError.value
                })
            extensions.append(self._get_extension_info(ext_id, prefs, error))

        return extensions
Пример #4
0
def test_find_extensions__test_extension__is_found():
    ext_dir = os.path.dirname(os.path.abspath(__file__))
    (id, path) = list(find_extensions(ext_dir))[0]
    assert id == 'test_extension'
    assert path == '%s/test_extension' % ext_dir