def site_versions(): ''' Compare current OutWiker and plugins versions with versions on the site ''' app_list = getLocalAppInfoList() # Downloading versions info print(u'Downloading version info files...\n') print(u'{: <20}{: <20}{}'.format(u'Title', u'Deployed version', u'Dev. version')) print(u'-' * 60) for localAppInfo in app_list: url = localAppInfo.updatesUrl name = localAppInfo.appname print(u'{:.<20}'.format(name), end=u'') try: appinfo = downloadAppInfo(url) if appinfo.currentVersion == localAppInfo.currentVersion: font = Fore.GREEN else: font = Fore.RED print(u'{siteversion:.<20}{devversion}'.format( siteversion=str(appinfo.currentVersion), devversion=font + str(localAppInfo.currentVersion) )) except (urllib.error.URLError, urllib.error.HTTPError) as e: print(Fore.RED + u'Error') print(str(e)) print(url) print('')
def upload_unstable(): """ Upload unstable version on the site """ versions = os.path.join(PATH_TO_WINDOWS_DISTRIBS, OUTWIKER_VERSIONS_FILENAME) upload_files = map(lambda item: os.path.join(PATH_TO_WINDOWS_DISTRIBS, item), FILES_FOR_UPLOAD_UNSTABLE_WIN) upload_files = upload_files + [versions] for fname in upload_files: print(u'Checking {}'.format(fname)) assert os.path.exists(fname) print('Checking versions') newOutWikerAppInfo = readAppInfo(versions) print('Download {}'.format(newOutWikerAppInfo.updatesUrl)) prevOutWikerAppInfo = downloadAppInfo(newOutWikerAppInfo.updatesUrl) if newOutWikerAppInfo.currentVersion < prevOutWikerAppInfo.currentVersion: print(Fore.RED + 'Error. New version < Prev version') sys.exit(1) elif newOutWikerAppInfo.currentVersion == prevOutWikerAppInfo.currentVersion: print (Fore.RED + 'Warning: Uploaded the same version') print ('Uploading...') for fname in upload_files: with cd(DEPLOY_UNSTABLE_PATH): basename = os.path.basename(fname) put(fname, basename)
def _build(self): # Path to archive with all plug-ins full_archive_path = self.get_plugins_pack_path() for plugin in self._plugins_list: # Path to versions.xml for current plugin xmlinfo_path = getPluginInfoPath(plugin) changelog_path = getPluginChangelogPath(plugin) localAppInfo = readAppInfo(xmlinfo_path) assert localAppInfo is not None assert localAppInfo.version is not None skip_plugin = False # Check for update if self._updatedOnly: url = localAppInfo.updatesUrl try: siteappinfo = downloadAppInfo(url) if localAppInfo.version == siteappinfo.version: skip_plugin = True except (urllib.error.URLError, urllib.error.HTTPError): pass # Archive a single plug-in if not skip_plugin: version = str(localAppInfo.version) archive_name = u'{}-{}.zip'.format(plugin, version) # Subpath to current plug-in archive plugin_dir_path = self._getSubpath(plugin) # Path to future archive archive_path = self._getSubpath(plugin, archive_name) os.mkdir(plugin_dir_path) shutil.copy(xmlinfo_path, plugin_dir_path) shutil.copy(changelog_path, plugin_dir_path) # Archive a single plug-in with lcd("plugins/{}".format(plugin)): local( '7z a -r -aoa -xr!*.pyc -xr!.ropeproject -x!doc -x!versions.xml "{}" ./*' .format(archive_path)) # Add a plug-in to full archive with lcd("plugins/{}".format(plugin)): local( '7z a -r -aoa -xr!*.pyc -xr!.ropeproject -x!versions.xml -w../ "{}" ./*' .format(full_archive_path))
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 _build(self): # Path to archive with all plug-ins full_archive_path = self._getSubpath(self._all_plugins_fname) for plugin in self._plugins_list: # Path to plugin.xml for current plugin xmlplugin_path = getPluginVersionsPath(plugin) localAppInfo = readAppInfo(xmlplugin_path) assert localAppInfo is not None assert localAppInfo.currentVersion is not None skip_plugin = False # Check for update if self._updatedOnly: url = localAppInfo.updatesUrl try: siteappinfo = downloadAppInfo(url) if localAppInfo.currentVersion == siteappinfo.currentVersion: skip_plugin = True except (urllib2.URLError, urllib2.HTTPError): pass # Archive a single plug-in if not skip_plugin: version = unicode(localAppInfo.currentVersion) archive_name = u'{}-{}.zip'.format(plugin, version) # Subpath to current plug-in archive plugin_dir_path = self._getSubpath(plugin) # Path to future archive archive_path = self._getSubpath(plugin, archive_name) os.mkdir(plugin_dir_path) shutil.copy(xmlplugin_path, plugin_dir_path) # Archive a single plug-in with lcd("plugins/{}".format(plugin)): local("7z a -r -aoa -xr!*.pyc -xr!.ropeproject ../../{} ./*".format(archive_path)) # Add a plug-in to full archive with lcd("plugins/{}".format(plugin)): local("7z a -r -aoa -xr!*.pyc -xr!.ropeproject -w../ ../../{} ./*".format(full_archive_path))