public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys/gkeys/
Date: Sat, 24 Dec 2016 09:41:17 +0000 (UTC)	[thread overview]
Message-ID: <1482572365.89d64ec041b3f4ce51d339e252073bf38bb77206.dolsen@gentoo> (raw)

commit:     89d64ec041b3f4ce51d339e252073bf38bb77206
Author:     aeroniero33 <justthisthing <AT> gmail <DOT> com>
AuthorDate: Tue Jun 21 01:40:28 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Dec 24 09:39:25 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=89d64ec0

Created the send-key function

<rebase edit> use _set_category() for consistency </edit Brian Dolbec>

 gkeys/gkeys/action_map.py | 11 ++++++++++-
 gkeys/gkeys/actions.py    | 27 +++++++++++++++++++++++++++
 gkeys/gkeys/lib.py        | 16 ++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py
index e4ea412..f372a5c 100644
--- a/gkeys/gkeys/action_map.py
+++ b/gkeys/gkeys/action_map.py
@@ -18,7 +18,7 @@ Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed',
     'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed']
 
 Key_Actions = ['----keys-----', 'check-key', 'installed',
-    'install-key', 'list-key', 'refresh-key', 'remove-key',
+    'install-key', 'list-key', 'send-key', 'refresh-key', 'remove-key',
     'search-key', 'spec-check']
 
 General_Actions = ['---general---', 'list-cats', 'sign','verify']
@@ -174,6 +174,15 @@ Gpg info.: pub   4096R/825533CBF6CD6C97 2014-10-03 [expires: 2017-09-17]
  Gkey task results:
     Done.''',
          }),
+    ('send-key', {
+        'func': 'sendkey',
+        'options': ['category', 'nick', 'name', 'fingerprint', 'keyid', 'keys',
+            'keydir', 'keyring'],
+        'desc': '''Uploads the selected gpg key''',
+        'long_desc': '''Uploads the selected gpg key''',
+        'example': '''gkeys send-key -C gentoo -n gkeys''',
+         }),
+
     ('move-key', {
         'func': 'movekey',
         'options': ['category', 'nick', 'name', 'fingerprint', 'keys',

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index aaa3f02..12b8efa 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -194,6 +194,33 @@ class Actions(ActionBase):
         return (False, messages)
 
 
+    def sendkey(self, args):
+        '''Send selected key(s) to the server'''
+        if not args.category:
+            return (False, ["Please specify seeds type."])
+        self.logger.debug(_unicode("ACTIONS: sendkey; args: %s")
+            % _unicode(args))
+        seeds = self.seedhandler.load_category(args.category, refresh=True)
+        self._set_category(args.category)
+        results = {}
+        kwargs = self.seedhandler.build_gkeydict(args)
+        keyresults = seeds.list(**kwargs)
+        if keyresults:
+            self.output('', '\n sending keys...')
+        else:
+            return (False, ["Key(s) not found"])
+        for gkey in sorted(keyresults):
+            self.logger.info(_unicode("Sending key %s, %s")
+                % (gkey.nick, gkey.pub_keyid))
+            self.output('', _unicode("  %s: %s")
+                % (gkey.name, ', '.join(gkey.pub_keyid)))
+            self.logger.debug(_unicode("ACTIONS: sendkey; gkey = %s")
+                % _unicode(gkey))
+            results[gkey.keydir] = self.gpg.send_keys(gkey)
+        return (True, ['Completed'])
+
+
+
     def listkey(self, args):
         '''Pretty-print the selected gpg key'''
         # get confirmation

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 5ad1aab..a8529f4 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -273,6 +273,22 @@ class GkeysGPG(GPG):
         self.logger.info('GPG return code: ' + str(result.returncode))
         return result
 
+    def send_keys(self, gkey):
+        '''Send gkey to keyserver
+        @param gkey: the gkey to be sent to the server
+        @return: GKEY_CHECK instance
+        '''
+        self.config.defaults['gpg_defaults'].append('--no-permission-warning')
+        self.set_keyserver()
+        self.set_keydir(gkey.keydir, 'send-keys', reset=True)
+        self.set_keyring('pubring.gpg', 'send-keys', reset=False)
+        self.set_keyseedfile(refresh=True)
+        self.logger.debug("LIB: send-keys, gkey: %s" % str(gkey))
+        self.logger.debug("** Calling runGPG with Running 'gpg %s --send-keys' for: %s"
+            % (' '.join(self.config.get_key('tasks', 'send-keys')), str(gkey)))
+        result = self.runGPG(task='send-keys', inputfile='')
+        self.logger.info('GPG return code: ' + str(result.returncode))
+        return result
 
     def check_keys(self, keydir, keyid, result=None):
         '''Check specified or all keys based on the seed type


             reply	other threads:[~2016-12-24  9:41 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-24  9:41 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-12-24  9:41 [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys/gkeys/ Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  4:52 [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24  9:13 ` [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482572365.89d64ec041b3f4ce51d339e252073bf38bb77206.dolsen@gentoo \
    --to=dolsen@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox