#!/usr/bin/python
# coding=utf-8
import sys
import json
import argparse
reload(sys)
sys.setdefaultencoding('utf-8')
def PrepareParser():
result=argparse.ArgumentParser(description="get data from jenkins")
result.add_argument("-jf","--jsonfile",help="jsonfile", required=True)
result.add_argument("-p","--platform",help="platform", required=True)
result.add_argument("-v","--app_version",help="app_version", required=True)
print result
return result
parser=PrepareParser()
args=parser.parse_args()
json_file=args.jsonfile
platform=args.platform
app_version=args.app_version
with open(json_file, 'rb') as f:
json_data = json.load(f)
for item in json_data:
if item["platform"]==platform:
item["ver"] = app_version
out = file(json_file, 'w+')
reContent = json.dump(json_data, out, ensure_ascii=False, indent=4)