def main(): viz.main() energy_data = read_csv() local_data = get_local() try: local_weather = get_weather(local_data) except Exception as e: print(e) local_weather = { "description": "n/a", "temp": "n/a", "feels_like": "n/a", "sunrise": "n/a", "sunset": "n/a" } #1. get IP list of addresses deviceList_data = get_ips() #creates deviceList_data #2. import json data as an array of dictionarys with open('servers.json') as f: server_data = json.load(f) #3. Add ips to server_data for item in server_data: for key, value in deviceList_data.items(): if item["name"] == key: item["ip"] = value print(server_data) #3. get solar data and add it to server_data for item in server_data: try: solar_data = get_pv_value(item["ip"]) status = "online" except Exception as e: solar_data = None status = "offline" item["solar_voltage"] = solar_data item["status"] = status try: time_stamp = getDeviceInfo('log')[0][0] print("time_stamp!!!!!!!!!!!!!!!!!!!!", time_stamp) time_stamp = ":".join(time_stamp.split(":")[0:-1]) except Exception as e: time_stamp = "N/A" item["time_stamp"] = time_stamp #4. get images and print(server_data) check_images(server_data) render_pages(local_data, energy_data, local_weather, server_data)
def viz(): search_text = session.get("search_text") search_type = session.get("search_type") pub_id = session.get("pub_id") pub_data = json.dumps(viz_mod.main(pub_id)) return render_template("viz.html", search_text = search_text, search_type = search_type, data = pub_data)
def update(): pub_id = int(request.args.get("pub_id").encode("utf-8")) pub_data = json.dumps(viz_mod.main(pub_id)) return pub_data
def main(): print(sys.argv) # Prints all arguments passed in cmd # to run: python HDTrees.py Trees/filename.tre tree_output = parse_file(sys.argv[1]) # 2nd arg (file with dir) viz.main(tree_output)