comparison refinery_test_tool.py @ 8:ee221004e3b4 draft

Add an option to produce empty files.
author hackdna
date Mon, 13 May 2013 17:59:26 -0400
parents a410fb6c43fa
children
comparison
equal deleted inserted replaced
7:5ac9c40dae35 8:ee221004e3b4
27 quit("Processing failed by request", args) 27 quit("Processing failed by request", args)
28 28
29 input = read_files(args.input_files) 29 input = read_files(args.input_files)
30 try: 30 try:
31 for out_file in args.output_files: 31 for out_file in args.output_files:
32 out_file.write("Output file name: " + out_file.name + "\n\n") 32 if args.empty_outfile:
33 out_file.write(input) 33 output = ''
34 else:
35 output = "Output file name: " + out_file.name + "\n\n" + input
36 out_file.write(output)
34 except IOError as e: 37 except IOError as e:
35 cleanup(args) 38 cleanup(args)
36 parser.error(e) 39 parser.error(e)
37 else: 40 else:
38 cleanup(args) 41 cleanup(args)
102 help='code to return on exit, default: %(default)s') 105 help='code to return on exit, default: %(default)s')
103 parser.add_argument('--stdout', action='store_true', 106 parser.add_argument('--stdout', action='store_true',
104 help='write a message to stdout') 107 help='write a message to stdout')
105 parser.add_argument('--stderr', action='store_true', 108 parser.add_argument('--stderr', action='store_true',
106 help='write a message to stderr') 109 help='write a message to stderr')
110 parser.add_argument('--empty_outfile', action='store_true',
111 help='produce empty output file(s)')
107 parser.add_argument('-p', '--p-fail', type=float, default=0.0, 112 parser.add_argument('-p', '--p-fail', type=float, default=0.0,
108 help='probability of execution failure, default: %(default)s') 113 help='probability of execution failure, default: %(default)s')
109 parser.add_argument('-s', '--sleep', dest='seconds', type=int, default=0, 114 parser.add_argument('-s', '--sleep', dest='seconds', type=int, default=0,
110 metavar='SECONDS', 115 metavar='SECONDS',
111 help='number of seconds to sleep, default: %(default)s') 116 help='number of seconds to sleep, default: %(default)s')