import json from bom_functions import get_sage_boms from bom_functions import write_bom_files # installation script , this will write all the boms # to disc write_bom_files(get_sage_boms())
return unequal_boms def update_git_bom(bom): for fname in os.listdir(path + '/' + bom): r = http.request( 'GET', 'https://raw.githubusercontent.com/hammonja/prod_data/master/BOMS/' + bom + '/' + fname) with open(path + '/' + bom + '/' + fname, 'w') as out: out.write(r.data.decode()) return # get current boms from sage' sage_boms = get_sage_boms() # get all boms from local machine' git_boms = get_git_boms() # compare boms' mis_match_boms = get_unequal_boms() # check if there is a mis-match' if len(mis_match_boms) > 0: # update boms from git that are not equal' for bom in mis_match_boms: update_git_bom(bom) # get all boms from git
if bom in git_boms.keys(): if sage_boms[bom.encode('utf-8')] <> git_boms[bom.encode('utf-8')]: unequal_boms.append(bom) else: # new bom unequal_boms.append(bom) return unequal_boms; def update_git_bom(bom): for fname in os.listdir(path+'/'+bom): r = requests.get('https://raw.githubusercontent.com/hammonja/prod_data/master/BOMS/'+bom+'/'+fname , verify=False) with open(path+'/'+bom+'/'+fname, 'w') as out: out.write(r.text) return # get current boms from sage sage_boms = get_sage_boms() # get all boms from git git_boms = get_git_boms() # check if there is a mis-match if sage_boms <> git_boms: # update boms from git that are not equal for bom in get_unequal_boms(): update_git_bom(bom) # get all boms from git again git_boms = get_git_boms() # check again