From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QF2Tr-0003cK-3J for garchives@archives.gentoo.org; Wed, 27 Apr 2011 11:00:27 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6205A1C0B0; Wed, 27 Apr 2011 10:58:45 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 10E5C1C0B0 for ; Wed, 27 Apr 2011 10:58:44 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6B63E1BC023 for ; Wed, 27 Apr 2011 10:58:44 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id CBD1C8050B for ; Wed, 27 Apr 2011 10:58:43 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <50833d06b407b6028d6b6ec66e938bc26cc23141.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/action.py X-VCS-Directories: layman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 50833d06b407b6028d6b6ec66e938bc26cc23141 Date: Wed, 27 Apr 2011 10:58:43 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 8ac0c198d241adf82b262b82ed8088d2 commit: 50833d06b407b6028d6b6ec66e938bc26cc23141 Author: Brian Dolbec gmail com> AuthorDate: Fri Mar 18 04:17:23 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Sun Mar 27 02:39:13 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D= commit;h=3D50833d06 remove no longer used action.py --- layman/action.py | 570 ------------------------------------------------= ------ 1 files changed, 0 insertions(+), 570 deletions(-) diff --git a/layman/action.py b/layman/action.py deleted file mode 100644 index 7199054..0000000 --- a/layman/action.py +++ /dev/null @@ -1,570 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -########################################################################= ######### -# LAYMAN ACTIONS -########################################################################= ######### -# File: action.py -# -# Handles layman actions. -# -# Copyright: -# (c) 2005 - 2008 Gunnar Wrobel -# Distributed under the terms of the GNU General Public Lice= nse v2 -# -# Author(s): -# Gunnar Wrobel -# -''' Provides the different actions that can be performed by layman.''' - -__version__ =3D "$Id: action.py 312 2007-04-09 19:45:49Z wrobel $" - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Dependencies -# -#-----------------------------------------------------------------------= -------- - -import os, sys - -from layman.dbbase import UnknownOverlayException -from layman.db import DB, RemoteDB -from layman.utils import path, delete_empty_directory -from layman.debug import OUT - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Class Fetch -# -#-----------------------------------------------------------------------= -------- - -class Fetch: - ''' Fetches the overlay listing. - - >>> import os - >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> cache =3D os.tmpnam() - >>> config =3D {'overlays' : - ... 'file://' + here + '/tests/testfiles/global-overlays.x= ml', - ... 'cache' : cache, - ... 'nocheck' : True, - ... 'proxy' : None, - ... 'quietness':3, - ... 'svn_command':'/usr/bin/svn', - ... 'rsync_command':'/usr/bin/rsync'} - >>> a =3D Fetch(config) - >>> a.run() - 0 - >>> b =3D open(a.db.path(config['overlays'])) - >>> b.readlines()[24] - ' A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org= ].\\n' - - >>> b.close() - >>> os.unlink(a.db.path(config['overlays'])) - - >>> a.db.overlays.keys() - [u'wrobel', u'wrobel-stable'] - ''' - - def __init__(self, config): - self.db =3D RemoteDB(config, ignore_init_read_errors=3DTrue) - - def run(self): - '''Fetch the overlay listing.''' - try: - self.db.cache() - except Exception, error: - OUT.die('Failed to fetch overlay list!\nError was: ' - + str(error)) - - return 0 - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Class Sync -# -#-----------------------------------------------------------------------= -------- - -class Sync: - ''' Syncs the selected overlays.''' - - def __init__(self, config): - - self.db =3D DB(config) - - self.rdb =3D RemoteDB(config) - - self.quiet =3D int(config['quietness']) < 3 - - self.selection =3D config['sync'] - - if config['sync_all'] or 'ALL' in self.selection: - self.selection =3D self.db.overlays.keys() - - enc =3D sys.getfilesystemencoding() - if enc: - self.selection =3D [i.decode(enc) for i in self.selection] - - def run(self): - '''Synchronize the overlays.''' - - OUT.debug('Updating selected overlays', 6) - - fatals =3D [] - warnings =3D [] - success =3D [] - for i in self.selection: - try: - odb =3D self.db.select(i) - except UnknownOverlayException, error: - fatals.append(str(error)) - continue - - try: - ordb =3D self.rdb.select(i) - except UnknownOverlayException: - warnings.append(\ - 'Overlay "%s" could not be found in the remote lists= .\n' - 'Please check if it has been renamed and re-add if n= ecessary.' % i) - else: - current_src =3D odb.sources[0].src - available_srcs =3D set(e.src for e in ordb.sources) - if ordb and odb and not current_src in available_srcs: - if len(available_srcs) =3D=3D 1: - plural =3D '' - candidates =3D ' %s' % tuple(available_srcs)[0] - else: - plural =3D 's' - candidates =3D '\n'.join((' %d. %s' % (i + 1, v= )) for i, v in enumerate(available_srcs)) - - warnings.append( - 'The source of the overlay "%(repo_name)s" seems= to have changed.\n' - 'You currently sync from\n' - '\n' - ' %(current_src)s\n' - '\n' - 'while the remote lists report\n' - '\n' - '%(candidates)s\n' - '\n' - 'as correct location%(plural)s.\n' - 'Please consider removing and re-adding the over= lay.' % { - 'repo_name':i, - 'current_src':current_src, - 'candidates':candidates, - 'plural':plural, - }) - - try: - self.db.sync(i, self.quiet) - success.append('Successfully synchronized overlay "' + i= + '".') - except Exception, error: - fatals.append( - 'Failed to sync overlay "' + i + '".\nError was: ' - + str(error)) - - if success: - OUT.info('\nSuccess:\n------\n', 3) - for i in success: - OUT.info(i, 3) - - if warnings: - OUT.warn('\nWarnings:\n------\n', 2) - for i in warnings: - OUT.warn(i + '\n', 2) - - if fatals: - OUT.error('\nErrors:\n------\n') - for i in fatals: - OUT.error(i + '\n') - return 1 - - return 0 - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Class Add -# -#-----------------------------------------------------------------------= -------- - -class Add: - ''' Adds the selected overlays.''' - - def __init__(self, config): - - self.config =3D config - - self.db =3D DB(config) - - self.rdb =3D RemoteDB(config) - - self.quiet =3D int(config['quietness']) < 3 - - self.selection =3D config['add'] - - enc =3D sys.getfilesystemencoding() - if enc: - self.selection =3D [i.decode(enc) for i in self.selection] - - if 'ALL' in self.selection: - self.selection =3D self.rdb.overlays.keys() - - def run(self): - '''Add the overlay.''' - - OUT.debug('Adding selected overlays', 6) - - result =3D 0 - - for i in self.selection: - try: - overlay =3D self.rdb.select(i) - except UnknownOverlayException, error: - OUT.warn(str(error), 2) - result =3D 1 - else: - OUT.debug('Selected overlay', 7) - try: - self.db.add(overlay, self.quiet) - OUT.info('Successfully added overlay "' + i + '".', = 2) - except Exception, error: - OUT.warn('Failed to add overlay "' + i + '".\nError = was: ' - + str(error), 2) - result =3D 1 - - return result - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Class Delete -# -#-----------------------------------------------------------------------= -------- - -class Delete: - ''' Deletes the selected overlays.''' - - def __init__(self, config): - - self.db =3D DB(config) - - self.selection =3D config['delete'] - - enc =3D sys.getfilesystemencoding() - if enc: - self.selection =3D [i.decode(enc) for i in self.selection] - - if 'ALL' in self.selection: - self.selection =3D self.db.overlays.keys() - - def run(self): - '''Delete the overlay.''' - - OUT.debug('Deleting selected overlays', 6) - - result =3D 0 - - for i in self.selection: - try: - overlay =3D self.db.select(i) - except UnknownOverlayException, error: - OUT.warn(str(error), 2) - - mdir =3D path([self.db.config['storage'], i]) - delete_empty_directory(mdir) - - result =3D 1 - else: - OUT.debug('Selected overlay', 7) - try: - self.db.delete(overlay) - OUT.info('Successfully deleted overlay "' + i + '".'= , 2) - except Exception, error: - OUT.warn('Failed to delete overlay "' + i + '".\nErr= or was: ' - + str(error), 2) - result =3D 1 - - return result - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Class Info -# -#-----------------------------------------------------------------------= -------- - -class Info: - ''' Print information about the specified overlays. - - >>> import os - >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> cache =3D os.tmpnam() - >>> config =3D {'overlays' : - ... 'file://' + here + '/tests/testfiles/global-overlays.x= ml', - ... 'cache' : cache, - ... 'proxy' : None, - ... 'info' : ['wrobel'], - ... 'nocheck' : False, - ... 'verbose': False, - ... 'quietness':3, - ... 'svn_command':'/usr/bin/svn', - ... 'rsync_command':'/usr/bin/rsync'} - >>> a =3D Info(config) - >>> a.rdb.cache() - >>> OUT.color_off() - >>> a.run() - * wrobel - * ~~~~~~ - * Source : https://overlays.gentoo.org/svn/dev/wrobel - * Contact : nobody@gentoo.org - * Type : Subversion; Priority: 10 - * Quality : experimental - * - * Description: - * Test - * - 0 - ''' - - def __init__(self, config): - - OUT.debug('Creating RemoteDB handler', 6) - - self.rdb =3D RemoteDB(config) - self.config =3D config - - self.selection =3D config['info'] - - enc =3D sys.getfilesystemencoding() - if enc: - self.selection =3D [i.decode(enc) for i in self.selection] - - if 'ALL' in self.selection: - self.selection =3D self.rdb.overlays.keys() - - def run(self): - ''' Print information about the selected overlays.''' - - result =3D 0 - - for i in self.selection: - try: - overlay =3D self.rdb.select(i) - except UnknownOverlayException, error: - OUT.warn(str(error), 2) - result =3D 1 - else: - # Is the overlay supported? - OUT.info(overlay.__str__(), 1) - if not overlay.is_official(): - OUT.warn('*** This is no official gentoo overlay ***= \n', 1) - if not overlay.is_supported(): - OUT.error('*** You are lacking the necessary tools t= o install t' - 'his overlay ***\n') - - return result - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Class List -# -#-----------------------------------------------------------------------= -------- - -class List(object): - def __init__(self, config, db): - self.config =3D config - self.db =3D db - - def _run(self, complain): - for summary, supported, official \ - in self.db.list(None, self.config['verbose'], self.confi= g['width']): - # Is the overlay supported? - if supported: - # Is this an official overlay? - if official: - OUT.info(summary, 1) - # Unofficial overlays will only be listed if we are not - # checking or listing verbose - elif complain: - # Give a reason why this is marked yellow if it is a= verbose - # listing - if self.config['verbose']: - OUT.warn('*** This is no official gentoo overlay= ***\n', 1) - OUT.warn(summary, 1) - # Unsupported overlays will only be listed if we are not che= cking - # or listing verbose - elif complain: - # Give a reason why this is marked red if it is a verbos= e - # listing - if self.config['verbose']: - OUT.error('*** You are lacking the necessary tools ' - 'to install this overlay ***\n') - OUT.error(summary) - - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Class ListRemote -# -#-----------------------------------------------------------------------= -------- - -class ListRemote(List): - ''' Lists the available overlays. - - >>> import os - >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> cache =3D os.tmpnam() - >>> config =3D {'overlays' : - ... 'file://' + here + '/tests/testfiles/global-overlays.x= ml', - ... 'cache' : cache, - ... 'proxy' : None, - ... 'nocheck' : False, - ... 'verbose': False, - ... 'quietness':3, - ... 'width':80, - ... 'svn_command':'/usr/bin/svn', - ... 'rsync_command':'/usr/bin/rsync'} - >>> a =3D ListRemote(config) - >>> a.db.cache() - >>> OUT.color_off() - >>> a.run() - * wrobel [Subversion] (https://o.g.o/svn/dev/wrob= el ) - 0 - >>> a.config['verbose'] =3D True - >>> a.run() - * wrobel - * ~~~~~~ - * Source : https://overlays.gentoo.org/svn/dev/wrobel - * Contact : nobody@gentoo.org - * Type : Subversion; Priority: 10 - * Quality : experimental - * - * Description: - * Test - * - * *** This is no official gentoo overlay *** - * - * wrobel-stable - * ~~~~~~~~~~~~~ - * Source : rsync://gunnarwrobel.de/wrobel-stable - * Contact : nobody@gentoo.org - * Type : Rsync; Priority: 50 - * Quality : experimental - * - * Description: - * A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org]. - * - 0 - ''' - - def __init__(self, config): - OUT.debug('Creating RemoteDB handler', 6) - super(ListRemote, self).__init__(config, RemoteDB(config)) - - def run(self): - ''' List the available overlays.''' - - OUT.debug('Printing remote overlays.', 8) - - _complain =3D self.config['nocheck'] or self.config['verbose'] - self._run(complain=3D_complain) - - return 0 - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Class ListLocal -# -#-----------------------------------------------------------------------= -------- - -class ListLocal(List): - ''' Lists the local overlays.''' - - def __init__(self, config): - OUT.debug('Creating DB handler', 6) - super(ListLocal, self).__init__(config, DB(config)) - - def run(self): - '''List the overlays.''' - - OUT.debug('Printing local overlays.', 8) - - self._run(complain=3DTrue) - - return 0 - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# MAIN -# -#-----------------------------------------------------------------------= -------- - -def main(config): - '''Dispatches to the actions the user selected. ''' - - # Given in order of precedence - actions =3D [('fetch', Fetch), - ('add', Add), - ('sync', Sync), - ('info', Info), - ('sync_all', Sync), - ('delete', Delete), - ('list', ListRemote), - ('list_local', ListLocal),] - - if True: # A hack to save diff with indentation changes only - - # Make fetching the overlay list a default action - if not 'nofetch' in config.keys(): - # Actions that implicitely call the fetch operation before - fetch_actions =3D ['sync', 'sync_all', 'list'] - for i in fetch_actions: - if i in config.keys(): - # Implicitely call fetch, break loop - Fetch(config).run() - break - - result =3D 0 - - # Set the umask - umask =3D config['umask'] - try: - new_umask =3D int(umask, 8) - old_umask =3D os.umask(new_umask) - except Exception, error: - OUT.die('Failed setting to umask "' + umask + '"!\nError was= : ' - + str(error)) - - for i in actions: - - OUT.debug('Checking for action', 7) - - if i[0] in config.keys(): - try: - result +=3D i[1](config).run() - except Exception, error: - OUT.error(str(error)) - result =3D -1 # So it cannot remain 0, i.e. success - break - - # Reset umask - os.umask(old_umask) - - if not result: - sys.exit(0) - else: - sys.exit(1) - -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -# -# Testing -# -#-----------------------------------------------------------------------= -------- - -if __name__ =3D=3D '__main__': - import doctest - - # Ignore warnings here. We are just testing - from warnings import filterwarnings, resetwarnings - filterwarnings('ignore') - - doctest.testmod(sys.modules[__name__]) - - resetwarnings()