dotfiles

config files and scripts at HOME.
git clone git://git.ricketyspace.net/dotfiles.git
Log | Files | Refs

commit 6b32a4ee6eb199fed5bf0da09d0f06c10dfdf025
parent 4f3369b6ef37dfd9df20fc5fad87aac5a947f405
Author: rsiddharth <rsiddharth@ninthfloor.org>
Date:   Tue, 31 May 2016 20:10:31 +0000

.bin/gnupg-backup: fingerprint instead of email.

The script now asks for the fingerprint connected with the gnupg key
instead of the email address.

Diffstat:
.bin/gnupg-backup | 28++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/.bin/gnupg-backup b/.bin/gnupg-backup @@ -73,18 +73,22 @@ def encrypt_it(f): OPT_SYM_ENCRYPT, f))) -def gnupg_export(email, directory): - """Export gnupg data connect with `email' to `directory`. +def gnupg_export(fpr, directory): + """Export gnupg data connected with fingerprint `fpr` to `directory`. + + This function will create directory call `gnupg-fpr` inside + `directory` and export gnupg data connected with fingerprint `fpr` + to 3 seperate files under `gnupg-fpr`. - This function will create directory call `gnupg-email` inside - `directory` and export write gnupg data connected with `email` to - 3 seperate files under `gnupg-email` """ - # First make the `gnupg-email` directory. + # Remove spaces from fingerprint + fpr = fpr.replace(' ', '') + + # First make the `gnupg-fpr` directory. try: export_dir = path.join(directory, - "%s%s" % (DIR_PREFIX, email)) + "%s%s" % (DIR_PREFIX, fpr)) os.mkdir(export_dir) except OSError: print "Looks like %s already exists" % export_dir @@ -94,7 +98,7 @@ def gnupg_export(email, directory): print "writing public key to %s" % pub_key with open(pub_key, 'w') as out: - call(shlex.split("%s %s %s" % (GPG, OPT_EXPORT, email)), + call(shlex.split("%s %s %s" % (GPG, OPT_EXPORT, fpr)), stdout=out) # Export secret key. @@ -102,7 +106,7 @@ def gnupg_export(email, directory): print "writing secret key to %s" % sec_key with open(sec_key, 'w') as out: - call(shlex.split("%s %s %s" % (GPG, OPT_EXPORT_SEC, email)), + call(shlex.split("%s %s %s" % (GPG, OPT_EXPORT_SEC, fpr)), stdout=out) # Export trust. @@ -127,14 +131,14 @@ def gnupg_export(email, directory): if __name__ == "__main__": parser = ArgumentParser() group = parser.add_argument_group('group') - group.add_argument('email', - help="email address to export") + group.add_argument('fpr', + help="fingerprint of key to export.") group.add_argument('directory', help="directory to export to") args = parser.parse_args() directory = path.expanduser(args.directory) if path.exists(directory): - gnupg_export(args.email, directory) + gnupg_export(args.fpr, directory) else: print "%s does not exist. Exiting..." % (directory)