Example #1
0
def _print_changelog(path_to_xml, lang):
    xml_content = readTextFile(path_to_xml)
    parser = XmlVersionParser([lang])
    appinfo = parser.parse(xml_content)
    generator = SiteChangelogGenerator(appinfo)
    changelog = generator.make()
    print(changelog)
Example #2
0
def _print_changelog(path_to_xml, lang):
    xml_content = readTextFile(path_to_xml)
    parser = XmlVersionParser([lang])
    appinfo = parser.parse(xml_content)
    generator = SiteChangelogGenerator(appinfo)
    changelog = generator.make()
    print(changelog)
Example #3
0
def plugins_list(lang):
    appinfo_list = []
    for plugin_name in PLUGINS_LIST:
        path_to_xml = os.path.join(PLUGINS_DIR,
                                   plugin_name,
                                   plugin_name,
                                   PLUGIN_VERSIONS_FILENAME)
        xml_content = readTextFile(path_to_xml)
        parser = XmlVersionParser([lang])
        appinfo = parser.parse(xml_content)
        appinfo_list.append(appinfo)

    generator = SitePluginsTableGenerator(appinfo_list)
    text = generator.make()
    print(text)
Example #4
0
    def __loadPluginInfo(self, plugin_fname):
        if not os.path.exists(plugin_fname):
            return None

        xml_content = readTextFile(plugin_fname)
        appinfo = XmlVersionParser().parse(xml_content)
        return appinfo
Example #5
0
    def test_author_04(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="en">
                    <author>
                        <name>Eugeniy Ilin</name>
                        <email>[email protected]</email>
                        <website>http://example.com/en/</website>
                    </author>
                </data>

                <data lang="ru_RU">
                    <author>
                        <name>Евгений Ильин</name>
                        <email>[email protected]</email>
                        <website>http://example.com/ru/</website>
                    </author>
                </data>
            </info>'''
        result = XmlVersionParser(['ru_RU', 'en']).parse(text)

        self.assertTrue(isinstance(result.author, AuthorInfo))
        self.assertEqual(result.author.name, 'Евгений Ильин')
        self.assertEqual(result.author.email, '*****@*****.**')
        self.assertEqual(result.author.website, 'http://example.com/ru/')
Example #6
0
    def getAppInfoFromUrl(self, url):
        """
        url - URL of path to file to read versions information.
        """
        if url is None:
            return None

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

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

        try:
            appinfo = XmlVersionParser([_(u'__updateLang'), u'en']).parse(text)
        except ValueError:
            logger.warning(u'Invalid format of {}'.format(url))
            return None

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

        return appinfo
Example #7
0
def getCurrentVersion():
    path = os.path.join(getCurrentDir(), VERSION_FILE_NAME)

    try:
        text = readTextFile(path)
        versionInfo = XmlVersionParser([_(VERSIONS_LANG), u'en']).parse(text)
    except EnvironmentError:
        return None

    return versionInfo.currentVersion
Example #8
0
    def test_requirements_packages_01(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <requirements>
                </requirements>
            </info>'''
        result = XmlVersionParser().parse(text)

        self.assertTrue(isinstance(result.requirements, RequirementsInfo))
        self.assertEqual(result.requirements.api_version, [])
Example #9
0
    def test_requirements_os_02(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <requirements>
                    <os>Linux, Windows</os>
                </requirements>
            </info>'''
        result = XmlVersionParser().parse(text)

        self.assertTrue(isinstance(result.requirements, RequirementsInfo))
        self.assertEqual(result.requirements.os, ['Linux', 'Windows'])
Example #10
0
def plugins_list(lang=None):
    '''
    Print plugins list for th site
    '''
    if lang is None:
        print_error(u'Error. No language specified')
        sys.exit(1)

    appinfo_list = []
    for plugin_name in PLUGINS_LIST:
        path_to_xml = os.path.join(PLUGINS_DIR, plugin_name, plugin_name,
                                   PLUGIN_VERSIONS_FILENAME)
        xml_content = readTextFile(path_to_xml)
        parser = XmlVersionParser([lang])
        appinfo = parser.parse(xml_content)
        appinfo_list.append(appinfo)

    generator = SitePluginsTableGenerator(appinfo_list)
    text = generator.make()
    print(text)
Example #11
0
    def test_updates_url_only(self):
        text = u'''<?xml version="1.1" encoding="UTF-8" ?>
            <info><updates>http://example.com/updates.xml</updates></info>'''
        result = XmlVersionParser().parse(text)

        self.assertEqual(result.author, None)
        self.assertEqual(result.appname, u"")
        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.description, u"")
        self.assertEqual(result.appwebsite, u"")
        self.assertEqual(result.updatesUrl, u"http://example.com/updates.xml")
Example #12
0
    def test_requirements_version_02(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <requirements>
                    <outwiker>2.0 dev</outwiker>
                </requirements>
            </info>'''
        result = XmlVersionParser().parse(text)

        self.assertTrue(isinstance(result.requirements, RequirementsInfo))
        self.assertEqual(result.requirements.os, [])
Example #13
0
    def test_name_only(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
<info><name>Имя приложения</name></info>'''
        result = XmlVersionParser().parse(text)

        self.assertEqual(result.author, None)
        self.assertEqual(result.appname, "Имя приложения")
        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.description, "")
        self.assertEqual(result.appwebsite, "")
        self.assertEqual(result.updatesUrl, "")
Example #14
0
    def test_empty_updates_url_only(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info><updates></updates></info>'''
        result = XmlVersionParser().parse(text)

        self.assertEqual(result.author, None)
        self.assertEqual(result.appname, "")
        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.description, "")
        self.assertEqual(result.appwebsite, "")
        self.assertEqual(result.updatesUrl, "")
Example #15
0
    def test_versions_list_empty(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="en">
                    <changelog></changelog>
                </data>
            </info>'''
        result = XmlVersionParser().parse(text)

        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.currentVersion, None)
Example #16
0
    def test_empty_02(self):
        text = '<?xml version="1.1" encoding="UTF-8" ?>'
        result = XmlVersionParser().parse(text)

        self.assertTrue(isinstance(result, AppInfo))
        self.assertEqual(result.author, None)
        self.assertEqual(result.appname, "")
        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.description, "")
        self.assertEqual(result.appwebsite, "")
        self.assertEqual(result.updatesUrl, "")
Example #17
0
    def test_requirements_os_01(self):
        text = u'''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <requirements>
                    <os>Linux</os>
                </requirements>
            </info>'''
        result = XmlVersionParser().parse(text)

        self.assertTrue(isinstance(result.requirements, RequirementsInfo))
        self.assertEqual(result.requirements.os, [u'Linux'])
        self.assertEqual(result.requirements.outwiker_version, None)
Example #18
0
    def test_empty_01(self):
        text = ""
        result = XmlVersionParser().parse(text)

        self.assertTrue(isinstance(result, AppInfo))
        self.assertEqual(result.author, None)
        self.assertEqual(result.appname, "")
        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.description, "")
        self.assertEqual(result.appwebsite, "")
        self.assertEqual(result.updatesUrl, "")
        self.assertEqual(result.requirements, None)
Example #19
0
    def test_description_03(self):
        text = u'''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="ru_RU"><description>Описание плагина</description></data>
            </info>'''
        result = XmlVersionParser([u'en']).parse(text)

        self.assertEqual(result.author, None)
        self.assertEqual(result.appname, u"")
        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.description, u"")
        self.assertEqual(result.appwebsite, u"")
        self.assertEqual(result.updatesUrl, u"")
Example #20
0
    def test_author_empty(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="en">
                    <author></author>
                </data>
            </info>'''
        result = XmlVersionParser().parse(text)

        self.assertTrue(isinstance(result.author, AuthorInfo))
        self.assertEqual(result.author.name, '')
        self.assertEqual(result.author.email, '')
        self.assertEqual(result.author.website, '')
Example #21
0
    def test_website_03(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="ru_RU"><website>http://example.com/ru/</website></data>
            </info>'''
        result = XmlVersionParser(['en']).parse(text)

        self.assertEqual(result.author, None)
        self.assertEqual(result.appname, "")
        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.description, "")
        self.assertEqual(result.appwebsite, "")
        self.assertEqual(result.updatesUrl, "")
Example #22
0
    def _processSource(self, source: SiteContentSource) -> None:
        if not os.path.exists(os.path.join(self._templates_path, source.template_file)):
            print_error('Template file not found: {}'.format(source.template_file))
            return

        if not os.path.exists(source.xml_file):
            print_error('XML file not found: {}'.format(source.xml_file))
            return

        xml_content = readTextFile(source.xml_file)
        parser = XmlVersionParser([source.lang])
        appinfo = parser.parse(xml_content)

        # template_content = readTextFile(source.template_file)
        # template = Template(template_content)
        template_env = Environment(loader=FileSystemLoader(self._templates_path))
        template = template_env.get_template(source.template_file)

        current_version = appinfo.versionsList[0]
        version_full_str = str(current_version.version)
        version_main = '.'.join([str(n)
                                 for n
                                 in current_version.version[:-1]]
                                )
        version_build = current_version.version[-1]
        versions_list = appinfo.versionsList
        date = current_version.date_str

        result = template.render(
            version_full=version_full_str,
            version_main=version_main,
            version_build=version_build,
            versions_list=versions_list,
            date=date,
        )

        template_name = os.path.basename(source.template_file)
        result_fname = os.path.join(self.build_dir, template_name)
        writeTextFile(result_fname, result)
Example #23
0
    def test_description_01(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="en"><description>My plugin</description></data>
            </info>'''
        result = XmlVersionParser(['ru_RU', 'en']).parse(text)

        self.assertEqual(result.author, None)
        self.assertEqual(result.appname, "")
        self.assertEqual(result.versionsList, [])
        self.assertEqual(result.description, "My plugin")
        self.assertEqual(result.appwebsite, "")
        self.assertEqual(result.updatesUrl, "")
Example #24
0
    def _processSource(self, source: SiteContentSource) -> None:
        if not os.path.exists(
                os.path.join(self._templates_path, source.template_file)):
            print_error('Template file not found: {}'.format(
                source.template_file))
            return

        if not os.path.exists(source.xml_file):
            print_error('XML file not found: {}'.format(source.xml_file))
            return

        xml_content = readTextFile(source.xml_file)
        parser = XmlVersionParser([source.lang])
        appinfo = parser.parse(xml_content)

        # template_content = readTextFile(source.template_file)
        # template = Template(template_content)
        template_env = Environment(
            loader=FileSystemLoader(self._templates_path))
        template = template_env.get_template(source.template_file)

        current_version = appinfo.versionsList[0]
        version_full_str = str(current_version.version)
        version_main = '.'.join([str(n) for n in current_version.version[:-1]])
        version_build = current_version.version[-1]
        versions_list = appinfo.versionsList
        date = current_version.date_str

        result = template.render(
            version_full=version_full_str,
            version_main=version_main,
            version_build=version_build,
            versions_list=versions_list,
            date=date,
        )

        template_name = os.path.basename(source.template_file)
        result_fname = os.path.join(self.build_dir, template_name)
        writeTextFile(result_fname, result)
Example #25
0
    def test_requirements_packages_05(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <requirements>
                    <api>1.0,2.0</api>
                </requirements>
            </info>'''
        result = XmlVersionParser().parse(text)

        api_versions_list = [(1, 0), (2, 0)]

        self.assertTrue(isinstance(result.requirements, RequirementsInfo))
        self.assertEqual(result.requirements.api_version, api_versions_list)
Example #26
0
    def test_versions_invalid(self):
        text = u'''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="en">
                    <changelog>
            <version>
            </version>
                    </changelog>
                </data>
            </info>'''
        result = XmlVersionParser().parse(text)

        self.assertEqual(len (result.versionsList), 0)
        self.assertEqual(result.currentVersion, None)
Example #27
0
def upload_plugin(*args):
    '''
    Upload plugin to site
    '''
    if len(args) == 0:
        args = PLUGINS_LIST

    version_str = getOutwikerVersionStr()

    for pluginname in args:
        path_to_plugin_local = os.path.join(BUILD_DIR, version_str,
                                            PLUGINS_DIR, pluginname)

        if not os.path.exists(path_to_plugin_local):
            continue

        path_to_xml_local = os.path.join(path_to_plugin_local,
                                         PLUGIN_VERSIONS_FILENAME)

        xml_content_local = readTextFile(path_to_xml_local)
        appinfo_local = XmlVersionParser().parse(xml_content_local)

        url = appinfo_local.updatesUrl
        try:
            appinfo_remote = downloadAppInfo(url)
        except Exception:
            appinfo_remote = None

        if (appinfo_remote is not None and
                appinfo_local.currentVersion < appinfo_remote.currentVersion):
            print_error(u'Error. New version < Prev version')
            sys.exit(1)
        elif (appinfo_remote is not None and appinfo_local.currentVersion
              == appinfo_remote.currentVersion):
            print_warning(u'Warning: Uploaded the same version')
        print_info(u'Uploading...')

        path_to_upload = os.path.dirname(
            appinfo_local.updatesUrl.replace(DEPLOY_SITE + u'/',
                                             DEPLOY_HOME_PATH))
        version_local = str(appinfo_local.currentVersion)
        archive_name = u'{}-{}.zip'.format(pluginname, version_local)
        path_to_archive_local = os.path.join(path_to_plugin_local,
                                             archive_name)

        with cd(path_to_upload):
            put(path_to_archive_local, archive_name)
            put(path_to_xml_local, PLUGIN_VERSIONS_FILENAME)
    site_versions()
Example #28
0
    def test_requirements_packages_05(self):
        text = u'''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <requirements>
                    <packages>
                        <core>1.0,2.0</core>
                    </packages>
                </requirements>
            </info>'''
        result = XmlVersionParser().parse(text)

        packages_dict = {u'core': [(1, 0), (2, 0)]}

        self.assertTrue(isinstance(result.requirements, RequirementsInfo))
        self.assertEqual(result.requirements.packages_versions, packages_dict)
Example #29
0
    def _getPluginsUpdateUrls(self, plugins):
        '''
        plugins - instance of the PluginsLoader
        Return dict which key is plugin name, value is updatesUrl
        '''
        result = {}

        for plugin in plugins:
            xmlPath = os.path.join(plugin._pluginPath,
                                   PLUGIN_VERSION_FILE_NAME)
            try:
                xmlText = readTextFile(xmlPath)
            except IOError:
                logger.warning(u"Can't read {}".format(xmlPath))
                continue

            versionParser = XmlVersionParser([_(u'__updateLang'), u'en'])
            try:
                result[plugin.name] = versionParser.parse(xmlText).updatesUrl
            except ValueError:
                logger.warning(u"Invalid format {}".format(xmlPath))
                continue

        return result
Example #30
0
    def test_author_01(self):
        text = u'''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="en">
                    <author>
                        <name>Eugeniy Ilin</name>
                        <email>[email protected]</email>
                        <website>http://example.com/en/</website>
                    </author>
                </data>
            </info>'''
        result = XmlVersionParser([u'en']).parse(text)

        self.assertTrue(isinstance (result.author, AuthorInfo))
        self.assertEqual(result.author.name, u'Eugeniy Ilin')
        self.assertEqual(result.author.email, u'*****@*****.**')
        self.assertEqual(result.author.website, u'http://example.com/en/')
Example #31
0
    def test_versions_01(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="en">
                    <changelog>
            <version number="1.0">
            </version>
                    </changelog>
                </data>
            </info>'''
        result = XmlVersionParser().parse(text)

        self.assertEqual(len(result.versionsList), 1)
        self.assertEqual(result.versionsList[0].version, Version(1, 0))
        self.assertEqual(result.versionsList[0].date_str, '')
        self.assertEqual(result.versionsList[0].hidden, False)
        self.assertEqual(len(result.versionsList[0].changes), 0)
        self.assertEqual(result.currentVersion, Version(1, 0))
Example #32
0
    def test_date(self):
        text = u'''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="ru">
                    <changelog>
            <version number="1.2" date="15 июня 2016">
            </version>
                    </changelog>
                </data>
            </info>'''
        result = XmlVersionParser([u'ru']).parse(text)

        self.assertEqual(len (result.versionsList), 1)
        self.assertEqual(result.versionsList[0].version, Version(1, 2))
        self.assertEqual(result.versionsList[0].date_str, u'15 июня 2016')
        self.assertEqual(result.versionsList[0].hidden, False)
        self.assertEqual(len (result.versionsList[0].changes), 0)
        self.assertEqual(result.currentVersion, Version(1, 2))
Example #33
0
    def test_hidden_03(self):
        text = '''<?xml version="1.1" encoding="UTF-8" ?>
            <info>
                <data lang="ru">
                    <changelog>
            <version number="1.2" hidden="True">
            </version>
                    </changelog>
                </data>
            </info>'''
        result = XmlVersionParser(['ru']).parse(text)

        self.assertEqual(len(result.versionsList), 1)
        self.assertEqual(result.versionsList[0].version, Version(1, 2))
        self.assertEqual(result.versionsList[0].date_str, '')
        self.assertEqual(result.versionsList[0].hidden, True)
        self.assertEqual(len(result.versionsList[0].changes), 0)
        self.assertEqual(result.currentVersion, Version(1, 2))
Example #34
0
def downloadAppInfo(url):
    downloader = Downloader(DOWNLOAD_TIMEOUT)
    version_parser = XmlVersionParser(['en'])
    xml_content = downloader.download(url)
    appinfo = version_parser.parse(xml_content)
    return appinfo