def getAvailablePackages(self): try: with open(utils.INDEX_PATH) as f: data = json.load(f) for metadata in data: if metadata['name'] == "rudder-plugin-%s" % (self.name): version = rpkg.PluginVersion(metadata['version']) package = rpkg.Rpkg(metadata['name'], self.name, metadata['path'], version, metadata) self.packagesInfo.add(package) if version.mode == 'release': self.releasePackagesInfo.add(package) elif version.mode == 'nightly': self.nightlyPackagesInfo.add(package) else: utils.fail( 'Unknown release mode, found %s and expecting release or nightly' % (version.mode)) except Exception as e: logger.error( "Verify that %s is correctly configured, run `rudder package update` and retry" % (utils.CONFIG_PATH)) utils.fail("could not parse the index file %s" % (utils.INDEX_PATH)) if not len(self.packagesInfo): logger.debug('No packages were found corresponding to %s' % (self.name)) else: logger.debug("Found corresponding packages: %s" % (self.packagesInfo))
def upgrade_all(mode, version): for p in utils.DB["plugins"].keys(): currentVersion = rpkg.PluginVersion(utils.DB["plugins"][p]["version"]) latestVersion = currentVersion pkgs = plugin.Plugin(p) pkgs.getAvailablePackages() if mode == "nightly": latest_packages = pkgs.getLatestCompatibleNightly(version) if (latest_packages is None): logger.debug( "No newer nightly %s compatible versions found for the plugin %s" % (mode, p)) else: latestVersion = latest_packages.version else: latest_packages = pkgs.getLatestCompatibleRelease(version) if (latest_packages is None): logger.debug( "No newer release %s compatible versions found for the plugin %s" % (mode, p)) else: latestVersion = latest_packages.version if currentVersion < latestVersion: logger.info( "The plugin %s is installed in version %s. The version %s %s is available, the plugin will be upgraded." % (p, currentVersion.pluginLongVersion, mode, latestVersion.pluginLongVersion)) package_install_latest([p], mode, version, exit_on_error=False) else: logger.info( "No newer %s compatible versions than %s found for the plugin %s." % (mode, currentVersion.pluginLongVersion, p))
def package_list_installed(): toPrint = [] printLatest = os.path.isfile(utils.INDEX_PATH) pluginName = [] version = [] latestRelease = [] for p in utils.DB["plugins"].keys(): pluginName.append(p) currentVersion = rpkg.PluginVersion(utils.DB["plugins"][p]["version"]) version.append(currentVersion.pluginLongVersion) extra = "" try: if printLatest: pkgs = plugin.Plugin(p) pkgs.getAvailablePackages() latestVersion = pkgs.getLatestCompatibleRelease().version if currentVersion < latestVersion: extra = "version %s is available"%(latestVersion.pluginLongVersion) latestRelease.append(latestVersion.pluginLongVersion + " " + extra) else: latestRelease.append("") except: latestRelease.append("") table = [ { "title": "Plugin Name", "value": pluginName }, { "title": "Version" , "value": version }, ] if printLatest: table.append({ "title": "Latest release", "value": latestRelease }) print(utils.dictToAsciiTable(table))
def upgrade_all(mode, quiet=False): for p in utils.DB["plugins"].keys(): currentVersion = rpkg.PluginVersion(utils.DB["plugins"][p]["version"]) pkgs = plugin.Plugin(p) pkgs.getAvailablePackages() if mode == "nightly": latestVersion = pkgs.getLatestCompatibleNightly().version else: latestVersion = pkgs.getLatestCompatibleRelease().version if currentVersion < latestVersion: print( "The plugin %s is installed in version %s. The version %s %s is available, the plugin will be upgraded." % (p, currentVersion.pluginLongVersion, mode, latestVersion.pluginLongVersion)) package_install_latest([p], mode, quiet) else: print("No newer %s compatible versions found for the plugin %s" % (mode, p))
def package_list_installed(): toPrint = [] printLatest = os.path.isfile(utils.INDEX_PATH) pluginName = [] version = [] latestRelease = [] currentStatus = [] for p in utils.DB["plugins"].keys(): pluginName.append(p) # Get version currentVersion = rpkg.PluginVersion(utils.DB["plugins"][p]["version"]) version.append(currentVersion.pluginLongVersion) # Get status # Only plugin containing jars can be disabled status = "enabled" if not os.path.exists(utils.PLUGINS_CONTEXT_XML): return text = open(utils.PLUGINS_CONTEXT_XML).read() match = re.search(r'<Set name="extraClasspath">(.*?)</Set>', text) if match: enabled = match.group(1).split(',') metadata = utils.DB["plugins"][p] if 'jar-files' in metadata: for j in metadata['jar-files']: if j not in enabled: status = "disabled" currentStatus.append(status) # Get latest available version extra = "" try: if printLatest: pkgs = plugin.Plugin(p) pkgs.getAvailablePackages() latestVersion = pkgs.getLatestCompatibleRelease().version if currentVersion < latestVersion: extra = "version %s is available" % ( latestVersion.pluginLongVersion) latestRelease.append(latestVersion.pluginLongVersion + " " + extra) else: latestRelease.append("") except: latestRelease.append("") table = [ { "title": "Plugin Name", "value": pluginName }, { "title": "Version", "value": version }, { "title": "Status", "value": currentStatus }, ] if printLatest: table.insert(2, {"title": "Latest release", "value": latestRelease}) print(utils.dictToAsciiTable(table))