from server2022_new import server2022 import firebase_admin from firebase_admin import credentials from firebase_admin import db from firebase_admin import messaging import time import threading import os from numba import jit, cuda import requests import traceback from firebase_admin import firestore cred = credentials.Certificate('servicekey.json') uid = 'TCXcp5VIsfhHZrh0nm2VsgBtcGy2' uid = 'snQYQZqQx3SmVbRztmEqYn5Mkcz2' try: firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) except: print('fire running') idsArr = [] tempObj = {} db_firestore = firestore.client() pending_list = db.reference('PaidMonitoredFields').child('PMF').child(uid).get(False, True) for (p,q) in pending_list.items(): p = str(p) fieldObj = db.reference('PaidMonitoredFields').child('PMF').child(uid).child(p).get() try: allPolygons = fieldObj["Polygons"] # for (polygonid, polygonObj) in allPolygons.items(): # name = polygonObj["Name"] # phoneNumber = polygonObj["PhoneNumber"] # db.reference('PaidPolygonsByPolygonID').child('PMF').child(uid).child(polygonid).child('Name').set(name) # db.reference('PaidPolygonsByPolygonID').child('PMF').child(uid).child(polygonid).child('PhoneNumber').set(phoneNumber) # time.sleep(0.1) # # r = requests.post('https://us-central1-farmbase-b2f7e.cloudfunctions.net/findHNIVillage', json = tempObj) except: print(p) print(traceback.format_exc()) db.reference('PaidMonitoredFields').child('PMF').child(uid).child(p).delete() db_firestore.collection(uid).document(p).delete() time.sleep(0.1)