dotfiles

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

commit e5ff5f1306e574031cf0f6961b23be2010731ed6
parent 9b56ca36d321cd8d77b16e715a4f6f2bd4b25827
Author: rsiddharth <rsiddharth@ninthfloor.org>
Date:   Tue, 14 Jun 2016 22:55:05 +0000

.bin/fdump: refactored.

Now it looks very similar to .bin/fdg

Diffstat:
.bin/fdump | 55++++++++++++++++++++++++++-----------------------------
1 file changed, 26 insertions(+), 29 deletions(-)

diff --git a/.bin/fdump b/.bin/fdump @@ -19,53 +19,50 @@ import shlex + from argparse import ArgumentParser from os import environ as env -from subprocess import call, PIPE - - -DEST = env.get('FDUMP_DEST') -"""Destination to dump file(s) to. """ +from subprocess import call +from sys import exit -IDENTITY_FILE = env.get('FDUMP_ID') -"""Path to SSH private key to ``scp`` :data:`DEST`. - -In SSH lingo the private key is called the 'identity file'. -""" +def dest(): + """destination to dump file(s) to. + """ + d = env.get('FDUMP_DEST') -SCP = 'scp' -"""`scp` command.""" + if d: + return d + else: + exit("Error: FDUMP_DEST not set!") -SCP_OPTS = '-i %s' % IDENTITY_FILE -"""`scp` options.""" +ident = env.get('FDUMP_ID') +"""path to ssh private key. +""" -cat = ' '.join +scp = 'scp' +"""`scp` command. -def make_cmd(srcs): - """Make command to do the dump. - """ - return shlex.split('%s %s %s %s' % (SCP, SCP_OPTS, cat(srcs), - DEST)) +""" -def dump(srcs): - """Dump `srcs` to DEST using ``scp``.""" - cmd = make_cmd(srcs) +def dump(file_): + """dump a file.""" + d = dest() - if call(cmd) == 0: - print('dumped.') + if ident: + call([scp, '-i', ident, file_, d]) else: - print('failed to dump.') + call([scp, file_, d]) if __name__ == '__main__': parser = ArgumentParser() - parser.add_argument('srcs', - nargs='+') + parser.add_argument('srcs', nargs='+') args = parser.parse_args() - dump(args.srcs) + + map(dump, args.srcs)