Create auto-image.py

This commit is contained in:
yakamok 2018-10-05 00:39:56 +02:00 committed by GitHub
parent 30f00c2114
commit 6d3b2d1c0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

27
auto-image.py Normal file
View File

@ -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)