Beispiel #1
0
 def run_all(self):
     """
     Finds all extensions in `EXTENSIONS_DIR` and runs them
     """
     for id, _ in find_extensions(self.extensions_dir):
         try:
             self.run(id)
         # pylint: disable=broad-except
         except Exception as e:
             logger.error("Couldn't run '%s'. %s: %s", id, type(e).__name__, e)
    def _get_all_extensions(self):
        extensions = []
        for ext_id, _ in find_extensions(EXTENSIONS_DIR):
            prefs = ExtensionPreferences.create_instance(ext_id)
            prefs.manifest.refresh()
            try:
                prefs.manifest.validate()
                prefs.manifest.check_compatibility()
            except (ManifestValidationError, VersionIncompatibilityError):
                continue
            extensions.append(self._get_extension_info(ext_id, prefs))

        return extensions
    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)
    def _get_all_extensions(self):
        extensions = []
        for ext_id, _ in find_extensions(EXTENSIONS_DIR):
            prefs = ExtensionPreferences.create_instance(ext_id)
            prefs.manifest.refresh()
            try:
                prefs.manifest.validate()
                prefs.manifest.check_compatibility()
            except (ManifestValidationError, VersionIncompatibilityError):
                continue
            extensions.append(self._get_extension_info(ext_id, prefs))

        return extensions
    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
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
Beispiel #7
0
 def _get_all_extensions(self):
     return [self._get_extension_info(ext_id) for ext_id, _ in find_extensions(EXTENSIONS_DIR)]