def write_fuel_data(): """Persist fuel data.""" fuel_data = fetch_fuel_data() fuel_json = parse_fuel_data(fuel_data) ts = temporal.datetimestamp() base_dir = '/dataVol/collector/json' if not os.path.exists(base_dir): os.makedirs(base_dir) fp = os.path.join(base_dir, 'fuel_data_' + ts + '.json') with open(fp, 'w') as fout: fout.write(fuel_json) logger.info('Fuel prices downloaded: %s' % fp)
def savejson(json_blob): fn = 'crimsonhexagon_' + temporal.datetimestamp() + '.json' fp = os.path.join(DL_PATH, fn) os.makedirs(DL_PATH, exist_ok = True) files.savejson(json_blob, fp) logger.info('Crimson Hexagon downloaded: %s' % fp)