diff options
author | Maximilian Krambach <[email protected]> | 2018-05-24 12:03:09 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-05-24 12:03:09 +0000 |
commit | e38b8beb20a8cfe897c378e3c20be80b8256159e (patch) | |
tree | 2b95b796bcc609fedc20197de866a28aef20f554 /lang/python/examples | |
parent | js: remove openpgp mode (diff) | |
parent | json: Put signature info before data output (diff) | |
download | gpgme-e38b8beb20a8cfe897c378e3c20be80b8256159e.tar.gz gpgme-e38b8beb20a8cfe897c378e3c20be80b8256159e.zip |
Merge branch 'master' into javascript-binding
Diffstat (limited to '')
-rwxr-xr-x | lang/python/examples/howto/decrypt-file.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lang/python/examples/howto/decrypt-file.py b/lang/python/examples/howto/decrypt-file.py index 60a050bd..b38acc79 100755 --- a/lang/python/examples/howto/decrypt-file.py +++ b/lang/python/examples/howto/decrypt-file.py @@ -38,7 +38,14 @@ else: newfile = input("Enter path and filename of file to save decrypted data to: ") with open(ciphertext, "rb") as cfile: - plaintext, result, verify_result = gpg.Context().decrypt(cfile) + try: + plaintext, result, verify_result = gpg.Context().decrypt(cfile) + except gpg.errors.GPGMEError as e: + plaintext = None + print(e) -with open(newfile, "wb") as nfile: - nfile.write(plaintext) +if plaintext is not None: + with open(newfile, "wb") as nfile: + nfile.write(plaintext) +else: + pass |