mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 03:33:11 +01:00
GPG: Improve error messages.
This commit is contained in:
parent
94ec830061
commit
0d820477c2
@ -32,6 +32,7 @@ import re
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
import functools
|
||||
|
||||
import supybot.gpg as gpg
|
||||
import supybot.conf as conf
|
||||
@ -50,6 +51,25 @@ except ImportError:
|
||||
# without the i18n module
|
||||
_ = lambda x: x
|
||||
|
||||
def check_gpg_available(f):
|
||||
if gpg.available:
|
||||
return f
|
||||
else:
|
||||
if not gpg.found_gnupg_lib:
|
||||
def newf(self, irc, *args):
|
||||
irc.error(_('gnupg features are not available because '
|
||||
'the python-gnupg library is not installed.'))
|
||||
elif not gpg.found_gnupg_bin:
|
||||
def newf(self, irc, *args):
|
||||
irc.error(_('gnupg features are not available because '
|
||||
'the gnupg executable is not installed.'))
|
||||
else:
|
||||
# This case should never happen.
|
||||
def newf(self, irc, *args):
|
||||
irc.error(_('gnupg features are not available.'))
|
||||
newf.__doc__ = f.__doc__
|
||||
newf.__name__ = f.__name__
|
||||
return newf
|
||||
|
||||
class GPG(callbacks.Plugin):
|
||||
"""Provides authentication based on GPG keys."""
|
||||
|
@ -32,6 +32,8 @@ import os
|
||||
import supybot.log as log
|
||||
import supybot.conf as conf
|
||||
|
||||
found_gnupg_lib = False
|
||||
found_gnupg_bin = False
|
||||
try:
|
||||
import gnupg
|
||||
except ImportError:
|
||||
@ -42,11 +44,16 @@ except ImportError:
|
||||
try:
|
||||
if gnupg:
|
||||
gnupg.GPG(gnupghome=None)
|
||||
found_gnupg_lib = found_gnupg_bin = True
|
||||
except TypeError:
|
||||
# This is the 'gnupg' library, not 'python-gnupg'.
|
||||
gnupg = None
|
||||
log.error('Cannot use GPG. gnupg (a Python package) is installed, '
|
||||
'but python-gnupg (an other Python package) should be '
|
||||
'installed instead.')
|
||||
except OSError:
|
||||
gnupg = None
|
||||
found_gnupg_lib = True
|
||||
log.error('Cannot use GPG. python-gnupg is installed but cannot '
|
||||
'find the gnupg executable.')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user