aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/examples/howto/export-secret-key.py
diff options
context:
space:
mode:
authorBen McGinnes <[email protected]>2018-09-24 23:59:31 +0000
committerBen McGinnes <[email protected]>2018-09-24 23:59:31 +0000
commit62e4e2cb5edb09183b9f9d448f992fe65cb6db85 (patch)
tree76330f0fe5dcd0af59c3d8cd38fddd3fa87e0398 /lang/python/examples/howto/export-secret-key.py
parentdocs: python bindings howto (diff)
downloadgpgme-62e4e2cb5edb09183b9f9d448f992fe65cb6db85.tar.gz
gpgme-62e4e2cb5edb09183b9f9d448f992fe65cb6db85.zip
docs and examples: python bindings
* Woumd up the "what's new" section. * Added an example for sending a key to the keyservers via hkp4py. * Updated the export key code to use a more complete check for the $GNUPGHOME location. * Expanded on the installation and reinstallation troubleshooting section. Tested-by: Ben McGinnes <[email protected]> Signed-off-by: Ben McGinnes <[email protected]>
Diffstat (limited to 'lang/python/examples/howto/export-secret-key.py')
-rwxr-xr-xlang/python/examples/howto/export-secret-key.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/lang/python/examples/howto/export-secret-key.py b/lang/python/examples/howto/export-secret-key.py
index ccc9f45d..e7d4e3af 100755
--- a/lang/python/examples/howto/export-secret-key.py
+++ b/lang/python/examples/howto/export-secret-key.py
@@ -54,12 +54,26 @@ else:
logrus = input("Enter the UID matching the secret key(s) to export: ")
homedir = input("Enter the GPG configuration directory path (optional): ")
-if homedir.startswith("~"):
- if os.path.exists(os.path.expanduser(homedir)) is True:
- c.home_dir = os.path.expanduser(homedir)
+if len(homedir) == 0:
+ homedir = None
+elif homedir.startswith("~"):
+ userdir = os.path.expanduser(homedir)
+ if os.path.exists(userdir) is True:
+ homedir = os.path.realpath(userdir)
+ else:
+ homedir = None
+else:
+ homedir = os.path.realpath(homedir)
+
+if os.path.exists(homedir) is False:
+ homedir = None
+else:
+ if os.path.isdir(homedir) is False:
+ homedir = None
else:
pass
-elif os.path.exists(homedir) is True:
+
+if homedir is not None:
c.home_dir = homedir
else:
pass