Django GPG: 3rd party app compatibility update
Update the django_gpg app to work with the latest version of the python-gnupg package (0.4.3). The python-gnupg now returns a more clear error message to differentiate between a bad passphrase and a missing passphrase. This improments allows the django_gpg to simplify its error message parsing and remove the literals: "ERROR_MSG_NEED_PASSPHRASE" and "ERROR_MSG_GOOD_PASSPHRASE". Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -11,9 +11,8 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .exceptions import NeedPassphrase, PassphraseError
|
||||
from .literals import (
|
||||
ERROR_MSG_NEED_PASSPHRASE, ERROR_MSG_BAD_PASSPHRASE,
|
||||
ERROR_MSG_GOOD_PASSPHRASE, KEY_TYPE_CHOICES, KEY_TYPE_SECRET,
|
||||
OUTPUT_MESSAGE_CONTAINS_PRIVATE_KEY
|
||||
ERROR_MSG_BAD_PASSPHRASE, ERROR_MSG_MISSING_PASSPHRASE,
|
||||
KEY_TYPE_CHOICES, KEY_TYPE_SECRET, OUTPUT_MESSAGE_CONTAINS_PRIVATE_KEY
|
||||
)
|
||||
from .managers import KeyManager
|
||||
from .runtime import gpg_backend
|
||||
@@ -124,10 +123,10 @@ class Key(models.Model):
|
||||
|
||||
logger.debug('file_sign_results.stderr: %s', file_sign_results.stderr)
|
||||
|
||||
if ERROR_MSG_NEED_PASSPHRASE in file_sign_results.stderr:
|
||||
if ERROR_MSG_BAD_PASSPHRASE in file_sign_results.stderr:
|
||||
raise PassphraseError
|
||||
elif ERROR_MSG_GOOD_PASSPHRASE not in file_sign_results.stderr:
|
||||
raise NeedPassphrase
|
||||
if ERROR_MSG_MISSING_PASSPHRASE in file_sign_results.stderr:
|
||||
raise NeedPassphrase
|
||||
|
||||
if ERROR_MSG_BAD_PASSPHRASE in file_sign_results.stderr:
|
||||
raise PassphraseError
|
||||
|
||||
return file_sign_results
|
||||
|
||||
Reference in New Issue
Block a user