Exemplo n.º 1
0
    def upload(self, plugins: List[str]):
        '''
        Upload plugin to site
        '''
        for pluginname in plugins:
            path_to_plugin_local = os.path.join(self.build_plugins_dir,
                                                pluginname)

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

            path_to_xml_changelog = getPluginChangelogPath(pluginname)
            changelog_xml_content = readTextFile(path_to_xml_changelog)
            changelog = ChangeLogFactory.fromString(changelog_xml_content, '')
            latest_version = changelog.latestVersion
            assert latest_version is not None

            print_info('Uploading...')

            for download in latest_version.downloads:
                url_elements = urlparse(download.href)
                server_src = '{scheme}://{netloc}/'.format(
                    scheme=url_elements.scheme, netloc=url_elements.netloc)

                upload_url = download.href.replace(server_src,
                                                   self.deploy_home_path)

                path_to_upload = os.path.dirname(upload_url)
                archive_name = os.path.basename(upload_url)

                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)
Exemplo n.º 2
0
def test_fromXmlChangeLog_versions_downloads_href():
    xmlChangeLog = XmlChangeLog()
    version = XmlChangeLogVersionInfo(number='1.0', status='dev', date=None)
    download = XmlDownload('https://example.com/download.zip')
    version.downloads.append(download)
    xmlChangeLog.versions.append(version)

    language = 'en'
    changelog = ChangeLogFactory.fromXmlChangeLog(xmlChangeLog, language)

    assert len(changelog.versions[0].downloads) == 1
    assert changelog.versions[0].downloads[
        0].href == 'https://example.com/download.zip'
    assert changelog.versions[0].downloads[0].requirements.os_list == []
    assert changelog.versions[0].downloads[0].requirements.api_list == []
Exemplo n.º 3
0
def test_fromXmlChangeLog_versions_changes():
    xmlChangeLog = XmlChangeLog()
    version = XmlChangeLogVersionInfo(number='1.0', status='dev', date=None)

    changes_en = [XmlChangeItem('Change 1'), XmlChangeItem('Change 2')]
    version.changes.set_for_language('en', changes_en)

    xmlChangeLog.versions.append(version)

    language = 'en'
    changelog = ChangeLogFactory.fromXmlChangeLog(xmlChangeLog, language)

    assert len(changelog.versions[0].changes) == 2
    assert changelog.versions[0].changes[0].description == 'Change 1'
    assert changelog.versions[0].changes[1].description == 'Change 2'
Exemplo n.º 4
0
def test_fromXmlChangeLog_versions_invalid_number():
    xmlChangeLog = XmlChangeLog()
    version_1 = XmlChangeLogVersionInfo(number='xxx')
    version_2 = XmlChangeLogVersionInfo(number='1.0', status='dev', date=None)

    xmlChangeLog.versions.append(version_1)
    xmlChangeLog.versions.append(version_2)

    language = ''
    changelog = ChangeLogFactory.fromXmlChangeLog(xmlChangeLog, language)

    assert len(changelog.versions) == 1

    assert changelog.versions[0].version == Version(1, 0, status=StatusSet.DEV)
    assert changelog.versions[0].downloads == []
    assert changelog.versions[0].changes == []
Exemplo n.º 5
0
def test_fromXmlChangeLog_versions_downloads_requirements_single():
    xmlChangeLog = XmlChangeLog()
    version = XmlChangeLogVersionInfo(number='1.0', status='dev', date=None)
    requirements = XmlRequirements(['Windows'], [(3, 868)])
    download = XmlDownload('https://example.com/download.zip', requirements)
    version.downloads.append(download)
    xmlChangeLog.versions.append(version)

    language = 'en'
    changelog = ChangeLogFactory.fromXmlChangeLog(xmlChangeLog, language)

    assert changelog.versions[0].downloads[0].requirements.os_list == [
        'Windows'
    ]
    assert changelog.versions[0].downloads[0].requirements.api_list == [(3,
                                                                         868)]
Exemplo n.º 6
0
def test_fromString_lang_ru_RU():
    changeLog = ChangeLogFactory.fromString(xmlexample, language='ru_RU')

    assert changeLog.versions[0].version == Version(1,
                                                    0,
                                                    status=StatusSet.BETA)
    assert changeLog.versions[0].changes[0].description == 'Исправлена ошибка'
    assert changeLog.versions[0].changes[
        1].description == 'Исправлена другая ошибка'
    assert changeLog.versions[0].downloads[
        0].href == 'http://example.com/application_v1_01.zip'
    assert changeLog.versions[0].downloads[
        1].href == 'http://example.com/application_v1_02.zip'
    assert changeLog.versions[0].downloads[0].requirements.os_list == [
        'Windows', 'Linux'
    ]
    assert changeLog.versions[0].downloads[1].requirements.os_list == [
        'Windows'
    ]
    assert changeLog.versions[0].downloads[0].requirements.api_list == [
        (3, 666), (3, 777)
    ]
    assert changeLog.versions[0].downloads[1].requirements.api_list == [(3,
                                                                         888)]

    assert changeLog.versions[1].version == Version(2, 0)
    assert changeLog.versions[1].changes[
        0].description == 'Исправлена ошибка - 2'
    assert changeLog.versions[1].changes[
        1].description == 'Исправлена другая ошибка - 2'
    assert changeLog.versions[1].downloads[
        0].href == 'http://example.com/application_v2_01.zip'
    assert changeLog.versions[1].downloads[
        1].href == 'http://example.com/application_v2_02.zip'
    assert changeLog.versions[1].downloads[0].requirements.os_list == [
        'Windows', 'Linux'
    ]
    assert changeLog.versions[1].downloads[1].requirements.os_list == [
        'Windows'
    ]
    assert changeLog.versions[1].downloads[0].requirements.api_list == [
        (3, 999), (3, 1111)
    ]
    assert changeLog.versions[1].downloads[1].requirements.api_list == [(3,
                                                                         2222)]
Exemplo n.º 7
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.versions_xml_file):
            print_error('XML file not found: {}'.format(
                source.versions_xml_file))
            return

        versions_xml_content = readTextFile(source.versions_xml_file)
        versions_info = ChangeLogFactory.fromString(versions_xml_content,
                                                    source.lang)

        template_env = Environment(
            loader=FileSystemLoader(self._templates_path))
        template = template_env.get_template(source.template_file)

        current_version = versions_info.latestVersion
        if current_version is not None:
            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]
        else:
            print_error('Invalid version in {}'.format(source.versions_xml_file))
            return

        versions_list = versions_info.versions

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

        template_name = os.path.basename(source.template_file)
        result_fname = os.path.join(self.build_dir, template_name)
        writeTextFile(result_fname, result)
Exemplo n.º 8
0
def test_fromXmlChangeLog_versions_simple():
    xmlChangeLog = XmlChangeLog()
    version_1 = XmlChangeLogVersionInfo(number='1.0', status='dev', date=None)
    version_2 = XmlChangeLogVersionInfo(number='2.0', status='beta', date=None)

    xmlChangeLog.versions.append(version_1)
    xmlChangeLog.versions.append(version_2)

    language = ''
    changelog = ChangeLogFactory.fromXmlChangeLog(xmlChangeLog, language)

    assert len(changelog.versions) == 2

    assert changelog.versions[0].version == Version(1, 0, status=StatusSet.DEV)
    assert changelog.versions[0].downloads == []
    assert changelog.versions[0].changes == []

    assert changelog.versions[1].version == Version(2,
                                                    0,
                                                    status=StatusSet.BETA)
    assert changelog.versions[1].downloads == []
    assert changelog.versions[1].changes == []
Exemplo n.º 9
0
def show_plugins_info():
    facts = BuildFacts()

    print('{:<20}{:<20}{}'.format('Plugin', 'Version', 'Release date'))
    for plugin in PLUGINS_LIST:
        changelog_path = facts.getPluginChangelogPath(plugin)
        changelog_txt = readTextFile(changelog_path)
        changelog = ChangeLogFactory.fromString(changelog_txt, '')
        latest_version = changelog.latestVersion

        date_str = (latest_version.date.strftime('%d.%m.%Y')
                    if latest_version.date else '-')

        color = ''
        if latest_version.date is None:
            color = Fore.RED
        elif latest_version.date.date() == datetime.date.today():
            color = Fore.GREEN

        print('{color}{name:.<20}{version:.<20}{date:^10}'.format(
            color=color,
            name=plugin,
            version=str(latest_version.version),
            date=date_str))
Exemplo n.º 10
0
def test_fromString_empty():
    changeLog = ChangeLogFactory.fromString('', language='ru')

    assert changeLog.versions == []