From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 9E79A1381F4 for ; Mon, 10 Dec 2012 04:57:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 896CC21C015; Mon, 10 Dec 2012 04:56:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CD0DF21C015 for ; Mon, 10 Dec 2012 04:56:56 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9570533D7A7 for ; Mon, 10 Dec 2012 04:56:55 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 2AF48E543C for ; Mon, 10 Dec 2012 04:56:54 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1355115368.ba85abe6630b8735459506ef210b4361c819174c.dol-sen@gentoo> Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/ X-VCS-Repository: proj/gentoo-keys X-VCS-Files: gkeys/cli.py X-VCS-Directories: gkeys/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: ba85abe6630b8735459506ef210b4361c819174c X-VCS-Branch: master Date: Mon, 10 Dec 2012 04:56:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b4b493f9-5d42-4a37-b62b-63294263efd9 X-Archives-Hash: 8392998128351621332be39e6c54d652 commit: ba85abe6630b8735459506ef210b4361c819174c Author: Brian Dolbec gentoo org> AuthorDate: Mon Dec 10 04:56:08 2012 +0000 Commit: Brian Dolbec gmail com> CommitDate: Mon Dec 10 04:56:08 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ba85abe6 add moveseed functionality. --- gkeys/cli.py | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 41 insertions(+), 4 deletions(-) diff --git a/gkeys/cli.py b/gkeys/cli.py index c3d0fd8..b000f58 100644 --- a/gkeys/cli.py +++ b/gkeys/cli.py @@ -68,6 +68,8 @@ class Main(object): # options parser.add_argument('-c', '--config', dest='config', default=None, help='The path to an alternate config file') + parser.add_argument('-d', '--dest', dest='destination', default=None, + help='The destination seed file or keyring for move, copy operations') parser.add_argument('-f', '--fingerprint', dest='fingerprint', default=None, help='The fingerprint of the the key') parser.add_argument('-n', '--name', dest='name', default=None, @@ -78,10 +80,10 @@ class Main(object): help='The longkeyid of the the key') parser.add_argument('-r', '--keyring', choices=['release', 'dev', 'overlays'], dest='keyring', default=None, - help='The keyring to use') + help='The keyring to use or update') parser.add_argument('-s', '--seeds', choices=['release', 'dev'], dest='seeds', default=None, - help='The seeds file to update') + help='The seeds file to use or update') parser.add_argument('-S', '--seedfile', dest='seedfile', default=None, help='The seedfile path to use') @@ -106,6 +108,7 @@ class Main(object): func = getattr(self, '_action_%s' % args.action) logger.debug('Found action: %s' % args.action) results = func(args) + # super simple output for the time being if self.print_results: print('\n\nGkey results:') print("\n".join([str(x) for x in results])) @@ -182,7 +185,7 @@ class Main(object): seeds = self._load_seeds(args.seeds) gkeys = self._action_listseed(args) if len(gkeys) == 1: - logger.debug("_action_removekey(); now deleting gkey: %s" % str(gkeys[0])) + logger.debug("_action_removeseed(); now deleting gkey: %s" % str(gkeys[0])) success = seeds.delete(gkeys[0]) if success: success = seeds.save() @@ -198,7 +201,41 @@ class Main(object): def _action_moveseed(self, args): '''Action moveseed method''' - pass + parts = self.build_gkeylist(args) + searchkey = GKEY._make(parts) + logger.debug("_action_moveseed(); gkey: %s" % str(searchkey)) + seeds = self._load_seeds(args.seeds) + kwargs = self.build_gkeydict(args) + sourcekeys = seeds.list(**kwargs) + dest = self._load_seeds(args.destination) + destkeys = dest.list(**kwargs) + messages = [] + if len(sourcekeys) == 1 and destkeys == []: + logger.debug("_action_moveseed(); now adding destination gkey: %s" + % str(sourcekeys[0])) + success = dest.add(sourcekeys[0]) + logger.debug("_action_moveseed(); success: %s" %str(success)) + logger.debug("_action_moveseed(); now deleting sourcekey: %s" % str(sourcekeys[0])) + success = seeds.delete(sourcekeys[0]) + if success: + success = dest.save() + logger.debug("_action_moveseed(); destination saved... %s" %str(success)) + success = seeds.save() + messages.extend(["Successfully Moved %s seed: %s" + % (args.seeds, str(success)), sourcekeys[0]]) + return messages + elif len(sourcekeys): + messages = ["Too many seeds found to remove"] + messages.extend(sourcekeys) + return messages + messages.append("Failed to Move seed:") + messages.append(searchkey) + messages.append('\n') + messages.append("Source seeds found...") + messages.extend(sourcekeys or ["None\n"]) + messages.append("Destination seeds found...") + messages.extend(destkeys or ["None\n"]) + return messages def _action_listkey(self, args):