def _print_linter_report(report: LinterReport): if report.status == LinterStatus.OK: print_info(' ' + report.message) elif report.status == LinterStatus.WARNING: print_warning(' ' + report.message) elif report.status == LinterStatus.ERROR: print_error(' ' + report.message) else: raise AssertionError
def deploy(self): # Check files for existence for fname in self.upload_files: if not os.path.exists(fname): print_error('Error. File not found: {}'.format(fname)) sys.exit(1) for fname in self.upload_files: with cd(self.deploy_path): basename = os.path.basename(fname) put(fname, basename)
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()
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()
def _check_outwiker_errors(): print_info('Start OutWiker information checking...') changelog_outwiker_fname = os.path.join(NEED_FOR_BUILD_DIR, OUTWIKER_VERSIONS_FILENAME) versions_outwiker = readTextFile(changelog_outwiker_fname) linter = LinterForOutWiker() status_outwiker, reports_outwiker = linter.check_all(versions_outwiker) for report in reports_outwiker: _print_linter_report(report) if status_outwiker == LinterStatus.OK: print_info('OutWiker information is OK') else: print_error('Outwiker information problems found') return status_outwiker
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)
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)
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)
def _check_plugins_errors(): print_info('Start plug-ins information checking...') linter = LinterForPlugin() sum_status = LinterStatus.OK for plugin in PLUGINS_LIST: print_info(' ' + plugin) changelog_fname = os.path.join(PLUGINS_DIR, plugin, PLUGIN_VERSIONS_FILENAME) changelog = readTextFile(changelog_fname) status, reports = linter.check_all(changelog) sum_status = sum_status & status for report in reports: _print_linter_report(report) if sum_status == LinterStatus.OK: print_info('Plug-ins information is OK') else: print_error('Plug-ins information problems found') return sum_status
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)