diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-02-05 12:24:55 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-02-05 12:24:55 -0500 |
commit | 15d0c7105cc69427ad027752a4ec3cb4c9790186 (patch) | |
tree | 4d98e2eae5542d9494a23bf8906cb745391c48fc /worker/worker1.py | |
download | htcondor_examples-15d0c7105cc69427ad027752a4ec3cb4c9790186.tar.gz |
Initial commit
Diffstat (limited to 'worker/worker1.py')
-rw-r--r-- | worker/worker1.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/worker/worker1.py b/worker/worker1.py new file mode 100644 index 0000000..5c474b2 --- /dev/null +++ b/worker/worker1.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +import os +import argparse + +PARSER = argparse.ArgumentParser() +PARSER.add_argument('--output-dir', '-o', default=os.path.abspath(os.curdir)) +PARSER.add_argument('INFILE', action='store', nargs='*', help='Input file') +ARGS = PARSER.parse_args() + +def do_work(ifile): + ofile = os.path.join(ARGS.output_dir, os.path.basename(ifile)) + in_data = [] + out_data = [] + + print('Loading {} ({} bytes)'.format(ifile, os.path.getsize(ifile))) + + with open(ifile) as fp: + for line in fp: + line = line.rstrip() + in_data.append(line) + + with open(ofile) as fp: + for value in in_data: + fp.writeline(value+1) + + + +if __name__ == '__main__': + + for infile in ARGS.INFILE: + do_work(os.path.abspath(infile)) + else: + print("No input file(s) received!") + exit(1) + + exit(0)
\ No newline at end of file |