mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
GPG: Improve error messages.
This commit is contained in:
parent
94ec830061
commit
0d820477c2
@ -32,6 +32,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
import functools
|
||||||
|
|
||||||
import supybot.gpg as gpg
|
import supybot.gpg as gpg
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
@ -50,6 +51,25 @@ except ImportError:
|
|||||||
# without the i18n module
|
# without the i18n module
|
||||||
_ = lambda x: x
|
_ = 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):
|
class GPG(callbacks.Plugin):
|
||||||
"""Provides authentication based on GPG keys."""
|
"""Provides authentication based on GPG keys."""
|
||||||
|
@ -32,6 +32,8 @@ import os
|
|||||||
import supybot.log as log
|
import supybot.log as log
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
|
|
||||||
|
found_gnupg_lib = False
|
||||||
|
found_gnupg_bin = False
|
||||||
try:
|
try:
|
||||||
import gnupg
|
import gnupg
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -42,11 +44,16 @@ except ImportError:
|
|||||||
try:
|
try:
|
||||||
if gnupg:
|
if gnupg:
|
||||||
gnupg.GPG(gnupghome=None)
|
gnupg.GPG(gnupghome=None)
|
||||||
|
found_gnupg_lib = found_gnupg_bin = True
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# This is the 'gnupg' library, not 'python-gnupg'.
|
# This is the 'gnupg' library, not 'python-gnupg'.
|
||||||
gnupg = None
|
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:
|
except OSError:
|
||||||
gnupg = None
|
gnupg = None
|
||||||
|
found_gnupg_lib = True
|
||||||
log.error('Cannot use GPG. python-gnupg is installed but cannot '
|
log.error('Cannot use GPG. python-gnupg is installed but cannot '
|
||||||
'find the gnupg executable.')
|
'find the gnupg executable.')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user