From 59684e0a3ae5f54440941219e3e25d3475aedec0 Mon Sep 17 00:00:00 2001 From: yakamok <38737288+yakamok@users.noreply.github.com> Date: Sat, 14 Jul 2018 22:31:24 +0200 Subject: [PATCH] changed how key id was retrieved added --with-colons to change how you get the key-id as this seems to be different on some systems for some reason this method seems to be reliable across Linux systems. --- upload-text-file.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/upload-text-file.py b/upload-text-file.py index 341c3a5..baccdb0 100644 --- a/upload-text-file.py +++ b/upload-text-file.py @@ -34,9 +34,10 @@ def parse_n_upload(upload_file): out, err = p.communicate() #get pub key - p=subprocess.Popen("gpg2 --list-key " + email, shell=True, stdout=subprocess.PIPE) + p=subprocess.Popen("gpg2 --list-key --with-colons " + email, shell=True, stdout=subprocess.PIPE) out, err = p.communicate() - key = out.split()[6] # parse out the key so we can use it to send keys to the key servers + # parse out the key id so we can use it to send keys to the key servers + key = key = [x.replace(':', '').replace('fpr', '') for x in out.split() if "fpr" in x][0] #read file and add it to the gpg key as plain text with open(upload_file, 'r') as infile: