Files
ThingsBoard/ThingsBoardClient/utilities.py
2022-08-20 10:06:20 -05:00

31 lines
633 B
Python

import json
def load_json_file(path):
try:
with open(path, "r") as f:
j = json.load(f)
return j
except Exception as e:
print("Error while loading JSON")
print(e)
def save_json_file(path,payload):
try:
with open(path, "w") as f:
json.dump(payload,f)
except Exception as e:
print("Error while saving JSON")
print(e)
def gal_to_bbl(value):
return value / 42.0
def bbl_to_gal(value):
return value * 42.0
def gpm_to_bpd(value):
return value * ((60 * 24) / 42.0)
def bpd_to_gpm(value):
return value * (42.0 / (24 * 60))