aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/examples/howto
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-05-24 12:03:09 +0000
committerMaximilian Krambach <[email protected]>2018-05-24 12:03:09 +0000
commite38b8beb20a8cfe897c378e3c20be80b8256159e (patch)
tree2b95b796bcc609fedc20197de866a28aef20f554 /lang/python/examples/howto
parentjs: remove openpgp mode (diff)
parentjson: Put signature info before data output (diff)
downloadgpgme-e38b8beb20a8cfe897c378e3c20be80b8256159e.tar.gz
gpgme-e38b8beb20a8cfe897c378e3c20be80b8256159e.zip
Merge branch 'master' into javascript-binding
Diffstat (limited to '')
-rwxr-xr-xlang/python/examples/howto/decrypt-file.py13
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