def manage_removeZenPacks(self, ids=(), REQUEST=None): """ Uninstall the given zenpacks. Uninstall the zenpack egg. If not in development mode then also delete the egg from the filesystem. """ import Products.ZenUtils.ZenPackCmd as ZenPackCmd # avoid circular imports from Products.ZenMessaging.queuemessaging.schema import removeZenPackQueuesExchanges # see ZEN-2682 only allow one zenpack to be removed at a time. This is because you # can select a zenpack and its dependent. If the dependent is removed first # you will get an error removing the zenpack if len(ids) > 1: msg = 'You can only remove one zenpack at a time.' if REQUEST: messaging.IMessageSender(self).sendToBrowser( 'Error', msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) raise ZenPackDependentsException(msg) if not getattr(self.dmd, 'ZenPackManager'): msg = 'Your Zenoss database appears to be out of date. Try ' \ 'running zenmigrate to update.' if REQUEST: messaging.IMessageSender(self).sendToBrowser( 'Error', msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) from ZenPack import ZenPackNeedMigrateException raise ZenPackNeedMigrateException(msg) canRemove, dependents = ZenPackCmd.CanRemoveZenPacks(self.dmd, ids) if not canRemove: msg = 'The following ZenPacks depend on one or more of the ' + \ ' ZenPacks you are trying to remove: %s' % ','.join(dependents) if REQUEST: messaging.IMessageSender(self).sendToBrowser( 'Error', msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) from ZenPack import ZenPackDependentsException raise ZenPackDependentsException(msg) for zpId in ids: zp = self.packs._getOb(zpId, None) if zp: if zp.isEggPack(): ZenPackCmd.RemoveZenPack(self.dmd, zpId, skipDepsCheck=True) audit('UI.ZenPack.Remove', zpId) else: os.system('%s --remove %s' % (binPath('zenpack'), zpId)) self._p_jar.sync() removeZenPackQueuesExchanges(zp.path()) if REQUEST: return self.callZenScreen(REQUEST)
def manage_removeZenPacks(self, ids=(), REQUEST=None): """ Uninstall the given zenpacks. Uninstall the zenpack egg. If not in development mode then also delete the egg from the filesystem. """ import Products.ZenUtils.ZenPackCmd as ZenPackCmd # avoid circular imports from Products.ZenMessaging.queuemessaging.schema import removeZenPackQueuesExchanges # see ZEN-2682 only allow one zenpack to be removed at a time. This is because you # can select a zenpack and its dependent. If the dependent is removed first # you will get an error removing the zenpack if len(ids) > 1: msg = "You can only remove one zenpack at a time." if REQUEST: messaging.IMessageSender(self).sendToBrowser("Error", msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) raise ZenPackDependentsException(msg) if not getattr(self.dmd, "ZenPackManager"): msg = "Your Zenoss database appears to be out of date. Try " "running zenmigrate to update." if REQUEST: messaging.IMessageSender(self).sendToBrowser("Error", msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) from ZenPack import ZenPackNeedMigrateException raise ZenPackNeedMigrateException(msg) canRemove, dependents = ZenPackCmd.CanRemoveZenPacks(self.dmd, ids) if not canRemove: msg = ( "The following ZenPacks depend on one or more of the " + " ZenPacks you are trying to remove: %s" % ",".join(dependents) ) if REQUEST: messaging.IMessageSender(self).sendToBrowser("Error", msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) from ZenPack import ZenPackDependentsException raise ZenPackDependentsException(msg) for zpId in ids: zp = self.packs._getOb(zpId, None) if zp: if zp.isEggPack(): ZenPackCmd.RemoveZenPack(self.dmd, zpId, skipDepsCheck=True) audit("UI.ZenPack.Remove", zpId) else: os.system("%s --remove %s" % (binPath("zenpack"), zpId)) self._p_jar.sync() removeZenPackQueuesExchanges(zp.path()) if REQUEST: return self.callZenScreen(REQUEST)
def manage_removeZenPacks(self, ids=(), REQUEST=None): """ Uninstall the given zenpacks. Uninstall the zenpack egg. If not in development mode then also delete the egg from the filesystem. """ import Products.ZenUtils.ZenPackCmd as ZenPackCmd # avoid circular imports from Products.ZenMessaging.queuemessaging.schema import removeZenPackQueuesExchanges if not getattr(self.dmd, 'ZenPackManager'): msg = 'Your Zenoss database appears to be out of date. Try ' \ 'running zenmigrate to update.' if REQUEST: messaging.IMessageSender(self).sendToBrowser( 'Error', msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) from ZenPack import ZenPackNeedMigrateException raise ZenPackNeedMigrateException(msg) canRemove, dependents = ZenPackCmd.CanRemoveZenPacks(self.dmd, ids) if not canRemove: msg = 'The following ZenPacks depend on one or more of the ' + \ ' ZenPacks you are trying to remove: %s' % ','.join(dependents) if REQUEST: messaging.IMessageSender(self).sendToBrowser( 'Error', msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) from ZenPack import ZenPackDependentsException raise ZenPackDependentsException(msg) for zpId in ids: zp = self.packs._getOb(zpId, None) if zp: if zp.isEggPack(): ZenPackCmd.RemoveZenPack(self.dmd, zpId, skipDepsCheck=True) audit('UI.ZenPack.Remove', zpId) else: os.system('%s --remove %s' % ( binPath('zenpack'), zpId)) self._p_jar.sync() removeZenPackQueuesExchanges(zp.path()) if REQUEST: return self.callZenScreen(REQUEST)
def run(self): """Execute the user's request""" if self.args: print "Require one of --install, --remove, --export, --create, or --list flags." self.parser.print_help() return if self.options.installPackName: audit('Shell.ZenPack.Install', zenpack=self.options.installPackName) elif self.options.fetch: audit('Shell.ZenPack.Fetch', zenpack=self.options.fetch) elif self.options.exportPack: audit('Shell.ZenPack.Export', zenpack=self.options.exportPack) elif self.options.removePackName: audit('Shell.ZenPack.Remove', zenpack=self.options.removePackName) elif self.options.createPackName: audit('Shell.ZenPack.Create', zenpack=self.options.createPackName) ZenPack.currentServiceId = self.options.serviceId if self.options.createPackName: devDir, packName = os.path.split(self.options.createPackName) try: self.connect() self.dmd.ZenPackManager.manage_addZenPack(packName, devDir=devDir) except Exception as ex: self.log.fatal("could not create zenpack: %s", ex) sys.exit(1) sys.exit(0) if self.options.installPackName: eggInstall = (self.options.installPackName.lower().endswith('.egg') or os.path.exists( os.path.join(self.options.installPackName, 'setup.py'))) if self.options.removePackName and self.options.filesOnly: # A files-only remove implies a files-only install. Egg packs are only supported here. installedEggs = [p for p in iter_entry_points('zenoss.zenpacks')] theOne = filter(lambda x: x.name == self.options.removePackName, installedEggs) if not theOne: raise ZenPackNotFoundException( "Specified zenpack not installed") if len(theOne) > 1: raise ZenPackException( "Multiple matching distributions for {} found - aborting.". format(self.options.removePackName)) actualZPDir = theOne[0].dist.location class ZPProxy: def __init__(self, zpId, actualPath): self.id = zpId self.actualPath = actualPath def path(self, *parts): return self.actualPath proxy = ZPProxy(self.options.removePackName, actualZPDir) for loader in (ZPL.ZPLDaemons(), ZPL.ZPLBin(), ZPL.ZPLLibExec()): loader.unload(proxy, None) try: os.system('pip uninstall -y "%s"' % self.options.removePackName) except Exception as ex: self.log.error('Could not uninstall "%s"', self.options.removePackName) raise ex # treat it as a fatal error return self.connect() if not getattr(self.dmd, 'ZenPackManager', None): raise ZenPackNeedMigrateException( 'Your Zenoss database appears' ' to be out of date. Try running zenmigrate to update.') if (self.options.installPackName or self.options.removePackName ) and not self._verifyZepRunning(timeout=600, delay=5): print >> sys.stderr, "Error: Required daemon zeneventserver not running." print >> sys.stderr, "Execute 'zeneventserver start' and retry the ZenPack installation." sys.exit(1) if self.options.installPackName: # Process each install filter utility - order does not matter for name, util in getUtilitiesFor(IZenPackInstallFilter): # Get normalized pack name to compare. Split on path separator # in case absolute path was given egg_name = EGG_NAME( os.path.basename( os.path.normpath(self.options.installPackName))) if not egg_name: self.stop('Could not determine egg name from "%s"' % self.options.installPackName) packName = egg_name.group('name') if not util.installable(packName): self.stop('Filter %s does not allow %s to be installed' \ % (name, self.options.installPackName)) if self.options.skipSameVersion and self._sameVersion(): return if not self.preInstallCheck(eggInstall): self.stop('%s not installed' % self.options.installPackName) if eggInstall: try: return EggPackCmd.InstallEggAndZenPack( self.dmd, self.options.installPackName, link=self.options.link, filesOnly=self.options.filesOnly, previousVersion=self.options.previousVersion, fromUI=self.options.fromui, serviceId=self.options.serviceId, ignoreServiceInstall=self.options.ignoreServiceInstall) except (OSError, ) as e: if self.options.link: self.stop('%s cannot be installed with --link option' % self.options.installPackName) else: self.stop('%s could not be installed' % self.options.installPackName) if os.path.isfile(self.options.installPackName): packName = self.extract(self.options.installPackName) elif os.path.isdir(self.options.installPackName): if self.options.link: packName = self.linkDir(self.options.installPackName) else: packName = self.copyDir(self.options.installPackName) else: self.stop( '%s does not appear to be a valid file or directory.' % self.options.installPackName) # We want to make sure all zenpacks have a skins directory and that it # is registered. The zip file may not contain a skins directory, so we # create one here if need be. The directory should be registered # by the zenpack's __init__.py and the skin should be registered # by ZPLSkins loader. skinsSubdir = zenPath('Products', packName, 'skins', packName) if not os.path.exists(skinsSubdir): os.makedirs(skinsSubdir, 0750) self.install(packName) elif self.options.fetch: return EggPackCmd.FetchAndInstallZenPack(self.dmd, self.options.fetch) elif self.options.exportPack: return EggPackCmd.ExportZenPack(self.dmd, self.options.exportPack) elif self.options.removePackName: try: self.dmd.startPauseADM() pack = self.dmd.ZenPackManager.packs._getOb( self.options.removePackName, None) if not pack: if not self.options.ifinstalled: self.log.info('ZenPack %s is not installed.', self.options.removePackName) return False else: if pack: removeZenPackQueuesExchanges(pack.path()) if pack.isEggPack(): return EggPackCmd.RemoveZenPack( self.dmd, self.options.removePackName) RemoveZenPack(self.dmd, self.options.removePackName, self.log) finally: self.dmd.stopPauseADM() elif self.options.list: for zpId in self.dmd.ZenPackManager.packs.objectIds(): try: zp = self.dmd.ZenPackManager.packs._getOb(zpId, None) except AttributeError: zp = None if not zp: desc = 'broken' elif zp.isEggPack(): try: desc = zp.eggPath() except DistributionNotFound: desc = "zenpack missing" else: desc = zp.path() print('%s (%s)' % (zpId, desc)) elif self.options.restore: self.log.info("Restoring zenpacks") self.restore() transaction.commit()
def run(self): """Execute the user's request""" if self.args: print "Require one of --install, --remove or --list flags." self.parser.print_help() return if self.options.installPackName: audit('Shell.ZenPack.Install', zenpack=self.options.installPackName) elif self.options.fetch: audit('Shell.ZenPack.Fetch', zenpack=self.options.fetch) elif self.options.removePackName: audit('Shell.ZenPack.Remove', zenpack=self.options.removePackName) if self.options.installPackName: eggInstall = (self.options.installPackName.lower().endswith('.egg') or os.path.exists( os.path.join(self.options.installPackName, 'setup.py'))) # files-only just lays the files down and doesn't "install" # them into zeo class ZPProxy: def __init__(self, zpId): self.id = zpId def path(self, *parts): return zenPath('Products', self.id, *parts) if self.options.installPackName and self.options.filesOnly: if eggInstall: return EggPackCmd.InstallZenPack(None, self.options.installPackName, filesOnly=True) packName = self.extract(self.options.installPackName) proxy = ZPProxy(packName) for loader in (ZPL.ZPLDaemons(), ZPL.ZPLBin(), ZPL.ZPLLibExec()): loader.load(proxy, None) return if self.options.removePackName and self.options.filesOnly: # Remove files-only is not yet supported for egg zenpacks # todo proxy = ZPProxy(self.options.removePackName) for loader in (ZPL.ZPLDaemons(), ZPL.ZPLBin(), ZPL.ZPLLibExec()): loader.unload(proxy, None) os.system('rm -rf %s' % zenPath('Products', self.options.removePackName)) return self.connect() if not getattr(self.dmd, 'ZenPackManager', None): raise ZenPackNeedMigrateException( 'Your Zenoss database appears' ' to be out of date. Try running zenmigrate to update.') if (self.options.installPackName or self.options.removePackName) and not self._verifyZepRunning(): print >> sys.stderr, "Error: Required daemon zeneventserver not running." print >> sys.stderr, "Execute 'zeneventserver start' and retry the ZenPack installation." sys.exit(1) if self.options.installPackName: if not self.preInstallCheck(eggInstall): self.stop('%s not installed' % self.options.installPackName) if eggInstall: return EggPackCmd.InstallEggAndZenPack( self.dmd, self.options.installPackName, link=self.options.link, filesOnly=False, previousVersion=self.options.previousVersion, fromUI=self.options.fromui) if os.path.isfile(self.options.installPackName): packName = self.extract(self.options.installPackName) elif os.path.isdir(self.options.installPackName): if self.options.link: packName = self.linkDir(self.options.installPackName) else: packName = self.copyDir(self.options.installPackName) else: self.stop( '%s does not appear to be a valid file or directory.' % self.options.installPackName) # We want to make sure all zenpacks have a skins directory and that it # is registered. The zip file may not contain a skins directory, so we # create one here if need be. The directory should be registered # by the zenpack's __init__.py and the skin should be registered # by ZPLSkins loader. skinsSubdir = zenPath('Products', packName, 'skins', packName) if not os.path.exists(skinsSubdir): os.makedirs(skinsSubdir, 0750) self.install(packName) elif self.options.fetch: return EggPackCmd.FetchAndInstallZenPack(self.dmd, self.options.fetch) elif self.options.removePackName: pack = self.dmd.ZenPackManager.packs._getOb( self.options.removePackName, None) if not pack: if not self.options.ifinstalled: self.log.info('ZenPack %s is not installed.' % self.options.removePackName) return False else: removeZenPackQueuesExchanges(pack.path()) if pack.isEggPack(): return EggPackCmd.RemoveZenPack( self.dmd, self.options.removePackName) RemoveZenPack(self.dmd, self.options.removePackName, self.log) elif self.options.list: for zpId in self.dmd.ZenPackManager.packs.objectIds(): try: zp = self.dmd.ZenPackManager.packs._getOb(zpId, None) except AttributeError: zp = None if not zp: desc = 'broken' elif zp.isEggPack(): desc = zp.eggPath() else: desc = zp.path() print('%s (%s)' % (zpId, desc)) transaction.commit()
def run(self): """Execute the user's request""" if self.args: print "Require one of --install, --remove or --list flags." self.parser.print_help() return if self.options.installPackName: audit('Shell.ZenPack.Install', zenpack=self.options.installPackName) elif self.options.fetch: audit('Shell.ZenPack.Fetch', zenpack=self.options.fetch) elif self.options.removePackName: audit('Shell.ZenPack.Remove', zenpack=self.options.removePackName) if self.options.installPackName: eggInstall = (self.options.installPackName.lower().endswith('.egg') or os.path.exists(os.path.join(self.options.installPackName, 'setup.py'))) # files-only just lays the files down and doesn't "install" # them into zeo class ZPProxy: def __init__(self, zpId): self.id = zpId def path(self, *parts): return zenPath('Products', self.id, *parts) if self.options.installPackName and self.options.filesOnly: if eggInstall: return EggPackCmd.InstallZenPack(None, self.options.installPackName, filesOnly=True) packName = self.extract(self.options.installPackName) proxy = ZPProxy(packName) for loader in (ZPL.ZPLDaemons(), ZPL.ZPLBin(), ZPL.ZPLLibExec()): loader.load(proxy, None) return if self.options.removePackName and self.options.filesOnly: # Remove files-only is not yet supported for egg zenpacks # todo proxy = ZPProxy(self.options.removePackName) for loader in (ZPL.ZPLDaemons(), ZPL.ZPLBin(), ZPL.ZPLLibExec()): loader.unload(proxy, None) os.system('rm -rf %s' % zenPath('Products', self.options.removePackName)) return self.connect() if not getattr(self.dmd, 'ZenPackManager', None): raise ZenPackNeedMigrateException('Your Zenoss database appears' ' to be out of date. Try running zenmigrate to update.') if (self.options.installPackName or self.options.removePackName) and not self._verifyZepRunning(): print >> sys.stderr, "Error: Required daemon zeneventserver not running." print >> sys.stderr, "Execute 'zeneventserver start' and retry the ZenPack installation." sys.exit(1) if self.options.installPackName: if not self.preInstallCheck(eggInstall): self.stop('%s not installed' % self.options.installPackName) if eggInstall: return EggPackCmd.InstallEggAndZenPack( self.dmd, self.options.installPackName, link=self.options.link, filesOnly=False, previousVersion= self.options.previousVersion, fromUI=self.options.fromui) if os.path.isfile(self.options.installPackName): packName = self.extract(self.options.installPackName) elif os.path.isdir(self.options.installPackName): if self.options.link: packName = self.linkDir(self.options.installPackName) else: packName = self.copyDir(self.options.installPackName) else: self.stop('%s does not appear to be a valid file or directory.' % self.options.installPackName) # We want to make sure all zenpacks have a skins directory and that it # is registered. The zip file may not contain a skins directory, so we # create one here if need be. The directory should be registered # by the zenpack's __init__.py and the skin should be registered # by ZPLSkins loader. skinsSubdir = zenPath('Products', packName, 'skins', packName) if not os.path.exists(skinsSubdir): os.makedirs(skinsSubdir, 0750) self.install(packName) elif self.options.fetch: return EggPackCmd.FetchAndInstallZenPack( self.dmd, self.options.fetch) elif self.options.removePackName: pack = self.dmd.ZenPackManager.packs._getOb( self.options.removePackName, None) if not pack: if not self.options.ifinstalled: self.log.info('ZenPack %s is not installed.' % self.options.removePackName) return False else: removeZenPackQueuesExchanges(pack.path()) if pack.isEggPack(): return EggPackCmd.RemoveZenPack( self.dmd, self.options.removePackName) RemoveZenPack(self.dmd, self.options.removePackName, self.log) elif self.options.list: for zpId in self.dmd.ZenPackManager.packs.objectIds(): try: zp = self.dmd.ZenPackManager.packs._getOb(zpId, None) except AttributeError: zp = None if not zp: desc = 'broken' elif zp.isEggPack(): desc = zp.eggPath() else: desc = zp.path() print('%s (%s)' % (zpId, desc)) transaction.commit()
def run(self): """Execute the user's request""" if self.args: print "Require one of --install, --remove, --export, --create, or --list flags." self.parser.print_help() return if self.options.installPackName: audit('Shell.ZenPack.Install', zenpack=self.options.installPackName) elif self.options.fetch: audit('Shell.ZenPack.Fetch', zenpack=self.options.fetch) elif self.options.exportPack: audit('Shell.ZenPack.Export', zenpack=self.options.exportPack) elif self.options.removePackName: audit('Shell.ZenPack.Remove', zenpack=self.options.removePackName) elif self.options.createPackName: audit('Shell.ZenPack.Create', zenpack=self.options.createPackName) ZenPack.currentServiceId = self.options.serviceId if self.options.createPackName: devDir, packName = os.path.split(self.options.createPackName) try: self.connect() self.dmd.ZenPackManager.manage_addZenPack(packName, devDir=devDir) except Exception as ex: self.log.fatal("could not create zenpack: %s", ex) sys.exit(1) sys.exit(0) if self.options.installPackName: eggInstall = (self.options.installPackName.lower().endswith('.egg') or os.path.exists(os.path.join(self.options.installPackName, 'setup.py'))) if self.options.removePackName and self.options.filesOnly: # A files-only remove implies a files-only install. Egg packs are only supported here. installedEggs = [ p for p in iter_entry_points('zenoss.zenpacks') ] theOne = filter(lambda x: x.name == self.options.removePackName, installedEggs) if not theOne: raise ZenPackNotFoundException("Specified zenpack not installed") if len(theOne) > 1: raise ZenPackException("Multiple matching distributions for {} found - aborting.".format(self.options.removePackName)) actualZPDir = theOne[0].dist.location class ZPProxy: def __init__(self, zpId, actualPath): self.id = zpId self.actualPath = actualPath def path(self, *parts): return self.actualPath proxy = ZPProxy(self.options.removePackName, actualZPDir) for loader in (ZPL.ZPLDaemons(), ZPL.ZPLBin(), ZPL.ZPLLibExec()): loader.unload(proxy, None) try: os.system('pip uninstall -y "%s"' % self.options.removePackName) except Exception as ex: self.log.error('Could not uninstall "%s"', self.options.removePackName) raise ex # treat it as a fatal error return self.connect() if not getattr(self.dmd, 'ZenPackManager', None): raise ZenPackNeedMigrateException('Your Zenoss database appears' ' to be out of date. Try running zenmigrate to update.') if (self.options.installPackName or self.options.removePackName) and not self._verifyZepRunning(timeout=600, delay=5): print >> sys.stderr, "Error: Required daemon zeneventserver not running." print >> sys.stderr, "Execute 'zeneventserver start' and retry the ZenPack installation." sys.exit(1) if self.options.installPackName: # Process each install filter utility - order does not matter for name, util in getUtilitiesFor(IZenPackInstallFilter): # Get normalized pack name to compare. Split on path separator # in case absolute path was given egg_name = EGG_NAME(os.path.basename(os.path.normpath(self.options.installPackName))) if not egg_name: self.stop('Could not determine egg name from "%s"' % self.options.installPackName) packName = egg_name.group('name') if not util.installable(packName): self.stop('Filter %s does not allow %s to be installed' \ % (name, self.options.installPackName)) if self.options.skipSameVersion and self._sameVersion(): return if not self.preInstallCheck(eggInstall): self.stop('%s not installed' % self.options.installPackName) if eggInstall: try: return EggPackCmd.InstallEggAndZenPack( self.dmd, self.options.installPackName, link=self.options.link, filesOnly=self.options.filesOnly, previousVersion= self.options.previousVersion, fromUI=self.options.fromui, serviceId=self.options.serviceId, ignoreServiceInstall=self.options.ignoreServiceInstall) except (OSError,) as e: if self.options.link: self.stop('%s cannot be installed with --link option' % self.options.installPackName) else: self.stop('%s could not be installed' % self.options.installPackName) if os.path.isfile(self.options.installPackName): packName = self.extract(self.options.installPackName) elif os.path.isdir(self.options.installPackName): if self.options.link: packName = self.linkDir(self.options.installPackName) else: packName = self.copyDir(self.options.installPackName) else: self.stop('%s does not appear to be a valid file or directory.' % self.options.installPackName) # We want to make sure all zenpacks have a skins directory and that it # is registered. The zip file may not contain a skins directory, so we # create one here if need be. The directory should be registered # by the zenpack's __init__.py and the skin should be registered # by ZPLSkins loader. skinsSubdir = zenPath('Products', packName, 'skins', packName) if not os.path.exists(skinsSubdir): os.makedirs(skinsSubdir, 0750) self.install(packName) elif self.options.fetch: return EggPackCmd.FetchAndInstallZenPack(self.dmd, self.options.fetch) elif self.options.exportPack: return EggPackCmd.ExportZenPack( self.dmd, self.options.exportPack) elif self.options.removePackName: try: self.dmd.startPauseADM() pack = self.dmd.ZenPackManager.packs._getOb( self.options.removePackName, None) if not pack: if not self.options.ifinstalled: self.log.info( 'ZenPack %s is not installed.', self.options.removePackName ) return False else: if pack: removeZenPackQueuesExchanges(pack.path()) if pack.isEggPack(): return EggPackCmd.RemoveZenPack( self.dmd, self.options.removePackName) RemoveZenPack(self.dmd, self.options.removePackName, self.log) finally: self.dmd.stopPauseADM() elif self.options.list: for zpId in self.dmd.ZenPackManager.packs.objectIds(): try: zp = self.dmd.ZenPackManager.packs._getOb(zpId, None) except AttributeError: zp = None if not zp: desc = 'broken' elif zp.isEggPack(): try: desc = zp.eggPath() except DistributionNotFound: desc = "zenpack missing" else: desc = zp.path() print('%s (%s)' % (zpId, desc)) elif self.options.restore: self.log.info("Restoring zenpacks") self.restore() transaction.commit()