~ubuntu-branches/ubuntu/precise/gozerbot/precise

« back to all changes in this revision

Viewing changes to debian/gozerbot/usr/lib/python2.5/site-packages/gozerplugs/plugs/pgp.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Malcolm
  • Date: 2008-06-02 19:26:39 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080602192639-3rn65nx4q1sgd6sy
Tags: 0.8.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# plugs/pgp.py
2
 
#
3
 
# (c) Wijnand 'tehmaze' Modderman - http://tehmaze.com
4
 
# BSD License
5
 
 
6
 
""" pgp utilities """
 
1
# gozerplugs/plugs/pgp.py
 
2
#
 
3
#
7
4
 
8
5
__author__ = "Wijnand 'tehmaze' Modderman - http://tehmaze.com"
9
6
__license__ = 'BSD'
10
7
 
 
8
from gozerbot.generic import rlog
11
9
from gozerbot.commands import cmnds
12
10
from gozerbot.examples import examples
13
 
from gozerbot.pgp import pgp
 
11
from gozerbot.pgp import pgp, NoGPGException
14
12
from gozerbot.plughelp import plughelp
15
13
import re
16
14
 
27
25
        return ievent.missing('<key id>')
28
26
    if not re_keyid.match(ievent.args[0]):
29
27
        return ievent.reply('invalid key id')
30
 
    (data, returncode) = pgp._gpg('--fingerprint', ievent.args[0])
 
28
    try:
 
29
        (data, returncode) = pgp._gpg('--fingerprint', ievent.args[0])
 
30
    except NoGPGException:
 
31
        ievent.reply('no gnupg installed')
 
32
        return
31
33
    results = []
32
34
    test_keypub = re_keypub.search(data)
33
35
    if test_keypub:
59
61
 
60
62
def handle_ppglist(bot, ievent):
61
63
    """ lists pgp keys """
62
 
    (data, returncode) = pgp._gpg('--fingerprint')
 
64
    try:
 
65
        (data, returncode) = pgp._gpg('--fingerprint')
 
66
    except NoGPGException:
 
67
        ievent.reply('no gnupg installed')
 
68
        return
63
69
    pubkeys = re_keypub.findall(data)
64
70
    if pubkeys:
65
71
        pubkeys = [x[2] for x in pubkeys]
69
75
        ievent.reply('no public keys installed')
70
76
 
71
77
cmnds.add('pgp-list', handle_ppglist, 'OPER')
 
78
examples.add('pgp-list', 'show list of registered pgp keys', 'pgp-list')
72
79
 
73
80
def handle_pgpremove(bot, ievent):
74
81
    """ remove pgp key """
82
89
        ievent.reply('failed')
83
90
 
84
91
cmnds.add('pgp-remove', handle_pgpremove, 'OPER')
 
92
examples.add('pgp-remove', 'remove a regitered pgp key', 'pgp-remove F9EBC3D8')