Exemplo n.º 1
0
def downloadAppInfo(url):
    downloader = Downloader(DOWNLOAD_TIMEOUT)

    try:
        xml_content = downloader.download(url)
        appinfo = AppInfoFactory.fromString(xml_content, '')
    except ValueError:
        appinfo = AppInfoFactory.fromString('', '')

    return appinfo
Exemplo n.º 2
0
    def getAppInfoFromUrl(self, url):
        """
        Get a AppInfo object for url.

        :param url:
            URL of path to file to read versions information.
        :returns:
            AppInfo or None
        """
        if url is None:
            return None

        logger.info(u'Downloading {}'.format(url))

        try:
            text = self._loader.load(url)
        except (urllib.error.HTTPError, urllib.error.URLError, ValueError):
            logger.warning(u"Can't download {}".format(url))
            return None

        try:
            appinfo = AppInfoFactory.fromString(text, '')
        except ValueError:
            logger.warning(u'Invalid format of {}'.format(url))
            return None

        if not appinfo.app_name.strip():
            return None

        return appinfo
Exemplo n.º 3
0
    def getInfo(self, pluginname: str, langlist=["en"]) -> Optional[AppInfo]:
        """
        Retrieve a AppInfo for plugin_name

        :param pluginname:
            name of the loaded plugin
        :param lang:
            langlist - list of the languages name ("en", "ru_RU" etc)
        :return:
            AppInfo for pluginname
            if pluginname cannot be located, then None is returned.
        :exception IOError:
            if plugin.xml cannot be read
        """
        if pluginname in self.loadedPlugins:
            module = self.loadedPlugins[pluginname].__class__.__module__
        else:
            module = ''

        xml_content = pkgutil.get_data(module, PLUGIN_INFO_FILE_NAME)
        if xml_content:
            language = ''
            return AppInfoFactory.fromString(xml_content.decode(), language)

        return None
Exemplo n.º 4
0
    def __loadPluginInfo(self, plugin_fname):
        if not os.path.exists(plugin_fname):
            return None

        xml_content = readTextFile(plugin_fname)
        language = ''
        appinfo = AppInfoFactory.fromString(xml_content, language)
        return appinfo
Exemplo n.º 5
0
def test_fromString_empty():
    appInfo = AppInfoFactory.fromString('', language='ru')

    assert appInfo.app_name == ''
    assert appInfo.website == ''
    assert appInfo.description == ''
    assert appInfo.version is None
    assert appInfo.authors == []
Exemplo n.º 6
0
def test_fromString_lang_default():
    appinfo = AppInfoFactory.fromString(xmlexample, language='jp')

    assert appinfo.app_name == 'Application name'
    assert appinfo.website == 'http://jenyay.net/en/'
    assert appinfo.description == 'Description'

    assert appinfo.authors[0].name == 'John'
    assert appinfo.authors[0].email == '*****@*****.**'
    assert appinfo.authors[0].website == 'http://example.com'

    assert appinfo.authors[1].name == 'Andrey'
    assert appinfo.authors[1].email == '*****@*****.**'
    assert appinfo.authors[1].website == 'http://example.com/andrey'

    assert appinfo.version == Version(2, 0, status=StatusSet.DEV)

    assert appinfo.requirements.os_list == ['Windows', 'Linux']
    assert appinfo.requirements.api_list == [(2, 222), (3, 333)]
Exemplo n.º 7
0
def test_fromString_lang_ru_RU():
    appinfo = AppInfoFactory.fromString(xmlexample, language='ru_RU')

    assert appinfo.app_name == 'Имя приложения'
    assert appinfo.website == 'http://jenyay.net/ru/'
    assert appinfo.description == 'Описание'

    assert appinfo.authors[0].name == 'Джон'
    assert appinfo.authors[0].email == '*****@*****.**'
    assert appinfo.authors[0].website == 'http://example.com/ru'

    assert appinfo.authors[1].name == 'Андрей'
    assert appinfo.authors[1].email == '*****@*****.**'
    assert appinfo.authors[1].website == 'http://example.com/andrey/ru'

    assert appinfo.version == Version(2, 0, status=StatusSet.DEV)

    assert appinfo.requirements.os_list == ['Windows', 'Linux']
    assert appinfo.requirements.api_list == [(2, 222), (3, 333)]
Exemplo n.º 8
0
def readAppInfo(fname: str) -> AppInfo:
    text = readTextFile(fname)
    return AppInfoFactory.fromString(text, '')