On 25 March 2015 at 03:39, pi-cheng.chen pi-cheng.chen@linaro.org wrote:
[snip]
- shutil.move(tmp.name, outfile)
the script is working with this change
+if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('-f', '--file', dest='infile', default='', help='input json filename')
- parser.add_argument('-o', '--out', dest='outfile', default='workload.json', help='output json filename');
- parser.add_argument('--instance', default=0, type=int, help='number of thread instance')
- parser.add_argument('--period', default=0, type=int, help='period of each thread/phase (ms)')
- parser.add_argument('--run', default=0, type=int, help='run time of each thread/phase (ms)')
- parser.add_argument('--sleep', default=0, type=int, help='sleep time of each thread/phase (ms)')
why have you used ms whereas us is used in the json file ?
- parser.add_argument('--loop', default=0,type=int, help='loop count of each thread/phase (-1 as infinite loop)')
- parser.add_argument('--loading', default=0, type=int, help='loading of each thread (%%)')
- parser.add_argument('--key', type=str, help='the key id of thread/phase in which the parameters will be changed')
- args = parser.parse_args()
- if not os.path.isfile(args.infile):
print 'ERROR: input file %s does not exist\n' %args.infile
parser.print_help()
sys.exit(2)
- doc = target = load_json_file(args.infile)
- if args.key:
target = find_dict_by_key(doc, args.key)
if not target:
print 'ERROR: key id %s is not found' %args.key
sys.exit(2)
- if args.instance > 0:
dict_find_and_replace_value(target, 'instance', args.instance)
- if args.period > 0:
dict_find_and_replace_value(target, 'period', args.period * 1000)
- if args.run > 0:
dict_find_and_replace_value(target, 'run', args.run * 1000)
- if args.sleep > 0:
dict_find_and_replace_value(target, 'sleep', args.sleep * 1000)
- if args.loop > 0 or args.loop == -1:
dict_find_and_replace_value(target, 'loop', args.loop)
- if args.loading > 0:
calculate_and_update_loading(target, args.loading);
- dump_json_file(doc, args.outfile)
-- 1.9.1