from xxlimited import new import fiona import requests import utm from geopy.geocoders import Nominatim import time import json import pandas as pd from fastkml import kml import xlrd from statistics import median import math import firebase_admin from firebase_admin import credentials from firebase_admin import db from firebase_admin import messaging import threading import xlsxwriter import numpy as np import os from numba import jit, cuda cred = credentials.Certificate('servicekey.json') try: firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) except: print('fire running') uid = 'snQYQZqQx3SmVbRztmEqYn5Mkcz2' mur_polygons = db.reference('PaidPolygonsByPolygonID').child('PMF').child(uid).get() for (polygonid, polygonobj) in mur_polygons.items(): try: fieldid = str(polygonobj["fieldID"]) polygonid = str(polygonid) db.reference('PaidMonitoredFields').child('PMF').child(uid).child(fieldid).child('Polygons').child(polygonid).set(polygonobj) time.sleep(0.1) except Exception as e: print(e) #mur_polygons = db.reference('PaidPolygonsByPolygonID').order_by_child(uid).start_at(1).end_at(20).get() # polygonobj = db.reference('PaidPolygonsByPolygonID').child('PMF').child(uid).child('1663472701433').get() # num = 0 # # for (polygonid, polygonobj) in mur_polygons.items(): # try: # #name = polygonobj["Name"] # r = requests.post('https://us-central1-farmbase-b2f7e.cloudfunctions.net/modifyPolygonField2', json = polygonobj) # dataObj = r.json() # #print(name) # print(dataObj) # time.sleep(0.5) # except Exception as e: # print(e) # print(num)