From 6d3b2d1c0dad433f473fca07df617caed454d767 Mon Sep 17 00:00:00 2001 From: yakamok <38737288+yakamok@users.noreply.github.com> Date: Fri, 5 Oct 2018 00:39:56 +0200 Subject: [PATCH] Create auto-image.py --- auto-image.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 auto-image.py diff --git a/auto-image.py b/auto-image.py new file mode 100644 index 0000000..c67b9e9 --- /dev/null +++ b/auto-image.py @@ -0,0 +1,27 @@ +# gpg test program +# +# This is just some nasty test code to add images automatically to a gpg pub key. +# Uses pexpect to interact with the shell. +# This does nothing alone its just an example, to use you need to write more code or +# add it to one of the existing programs in this repo. + +import pexpect +import sys +import time + +email = "fake@mail" +imagefile = '/usr/path/to/image/file.jpg' +child = pexpect.spawn('gpg --edit-key ' + email) +child.logfile = sys.stdout + +child.expect('gpg>') +child.sendline('addphoto') +child.expect('Enter JPEG filename for photo ID: ') +child.sendline(imagefile) +child.expect('y+') +child.send('y\n') +child.expect('Is this photo correct (y/N/q)?') +child.send('y\n') +child.expect('gpg> ') +child.sendline('save') +child.expect (pexpect.EOF)