From 62e4e2cb5edb09183b9f9d448f992fe65cb6db85 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 25 Sep 2018 09:59:31 +1000 Subject: 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 Signed-off-by: Ben McGinnes --- lang/python/examples/howto/export-minimised-key.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'lang/python/examples/howto/export-minimised-key.py') diff --git a/lang/python/examples/howto/export-minimised-key.py b/lang/python/examples/howto/export-minimised-key.py index 9d5f8488..a5a453ce 100755 --- a/lang/python/examples/howto/export-minimised-key.py +++ b/lang/python/examples/howto/export-minimised-key.py @@ -51,12 +51,26 @@ else: logrus = input("Enter the UID matching the 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 -- cgit v1.2.3