How to use initialize_app method in tempest

Best Python code snippet using tempest_python

Database_class.py

Source:Database_class.py Github

copy

Full Screen

...40 import firebase_admin41 import pathlib42 if not firebase_admin._apps:43 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")44 initialize_app(cred, {'storageBucket': 'farmzon-abdcb.appspot.com'})45 # print(uploadima_app.name)46 list_food = [47 "avocado.png", "pea.png", "carrot.png", "cucumber.png",48 "capsicum.png", "onion.png", "clove.png"49 ]50 for i in range(list_food.__len__()):51 fileName = "farmzon database/herbs/herbs/" + list_food[i]52 bucket = storage.bucket()53 suf = pathlib.Path(list_food[i]).suffix54 name = self.rchop(list_food[i], ".png")55 blob = bucket.blob("Categories_url/herbs/" + name.lower())56 blob.upload_from_filename(fileName)57 blob.make_public()58 self.url = blob.public_url59 print("your file url", self.url)60 self.product_image = self.url61 self.put_in_database(self.url, name.lower())6263 def upload_product_image(self, home, cate, path, name):64 from connection_status import connect65 if connect():66 from firebase_admin import credentials, initialize_app, storage67 import firebase_admin68 import pathlib69 if not firebase_admin._apps:70 fileName = path71 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")72 initialize_app(cred, {'storageBucket': 'farmzon-abdcb.appspot.com'})73 bucket = storage.bucket()74 blob = bucket.blob(home + "/" + cate + "/" + name)75 blob.upload_from_filename(path)76 blob.make_public()77 self.url = blob.public_url78 print("your file url", self.url)7980 def put_in_database(self, url, name):81 from connection_status import connect82 if connect():83 from firebase_admin import credentials, initialize_app, db84 import firebase_admin85 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")86 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},87 name="new" + name)88 # print(default_app.name)89 users = db.reference("Categories_url", default_app, 'https://farmzon-abdcb.firebaseio.com/').child(90 "herbs").child(name)91 users.set({92 "url": url93 })9495 def upload_data_user(self, name, phone, password, city, address, email, location, latitude, longitude):96 from connection_status import connect97 if connect():98 from main import number_of_app99 from firebase_admin import credentials, initialize_app, db100 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")101 if number_of_app.times == 0:102 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})103 print(default_app.name)104 number_of_app.times += 1105 else:106 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},107 name="default" + str(number_of_app.times))108 print(default_app.name)109 number_of_app.times += 1110 ref = db.reference('Users').child(phone)111 ref.set({112 "name": name,113 "phone": phone,114 "password": password,115 "city": str(city),116 "address": address,117 "location": location,118 "latitude": latitude,119 "longitude": longitude,120 "email": email,121 "date": get_date(),122 "Purchased": "0",123 "Followed": "0",124 "Orders": "0",125 })126 print("ok")127128 def upload_data_admin(self, name, phone, password, city, address, email, business):129 from connection_status import connect130 if connect():131 from main import number_of_app132 from firebase_admin import credentials, initialize_app, db133 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")134 if number_of_app.times == 0:135 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})136 print(default_app.name)137 number_of_app.times += 1138 else:139 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},140 name="default" + str(number_of_app.times))141 print(default_app.name)142 number_of_app.times += 1143 ref = db.reference('Admins').child(phone)144 ref.set({145 "name": name,146 "phone": phone,147 "password": password,148 "city": str(city),149 "address": address,150 "email": email,151 "date": get_date(),152 "b_type": business,153 "Purchased": "0",154 "Followers": "0",155 "Products": "0",156 })157158 def Signing_in(self, phone, password):159 from connection_status import connect160 if connect():161 from main import number_of_app162163 from firebase_admin import credentials, initialize_app, db164 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")165 if number_of_app.times == 0:166 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})167 print(default_app.name)168 number_of_app.times += 1169 else:170 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},171 name="default" + str(number_of_app.times))172 print(default_app.name)173 number_of_app.times += 1174 users = db.reference("Users")175 sers = db.reference("Users")176 user = users.get()177 ser = sers.order_by_child("city").equal_to("arusha").get()178 print(ser)179 if phone in user.keys():180 password_collector = db.reference("Users").child(phone).child("password")181 if password == password_collector.get():182 # take name183 name_collector = db.reference("Users").child(phone).child("name")184 Upload_image.name = name_collector.get()185186 # take image187 first_char = Upload_image.name[0]188 image = db.reference("Categories_url").child("letter_name").child(first_char).child("url")189 Upload_image.image = image.get()190 print(Upload_image.image)191192 # take purchase193 purchase_collector = db.reference("Users").child(phone).child("Purchased")194 Upload_image.purchased_admin = purchase_collector.get()195196 return True197 else:198 return False199 else:200 return False201202 def Signing_in_admin(self, phone, password):203 from connection_status import connect204 if connect():205 from main import number_of_app206 from firebase_admin import credentials, initialize_app, db207 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")208 if number_of_app.times == 0:209 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})210 print(default_app.name)211 number_of_app.times += 1212 else:213 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},214 name="default" + str(number_of_app.times))215 print(default_app.name)216 number_of_app.times += 1217 admins = db.reference("Admins")218 admin = admins.get()219 if phone in admin.keys():220 print("ok")221 password_collector = db.reference("Admins").child(phone).child("password")222 if password == password_collector.get():223224 # take name225 name_collector = db.reference("Admins").child(phone).child("name")226 Upload_image.name_admin = name_collector.get()227228 # take image229 first_char = Upload_image.name_admin[0]230 image = db.reference("Categories_url").child("letter_name").child(first_char).child("url")231 Upload_image.image_admin = image.get()232 print(Upload_image.image_admin)233234 # take followers235 follower_collector = db.reference("Admins").child(phone).child("Followers")236 Upload_image.follower_admin = follower_collector.get()237238 # take purchase239 purchase_collector = db.reference("Admins").child(phone).child("Purchased")240 Upload_image.purchased_admin = purchase_collector.get()241242 # take products243 product_collector = db.reference("Admins").child(phone).child("Products")244 Upload_image.product_admin = product_collector.get()245 return True246 else:247 return False248 else:249 print("not ok")250 return False251252 def Product_Commiter(self, identity, name, image_path, max, min, date, month, year, state, time):253 from connection_status import connect254 if connect():255 from main import number_of_app256257 from firebase_admin import credentials, initialize_app, db258 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")259 if number_of_app.times == 0:260 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})261 print(default_app.name)262 number_of_app.times += 1263 else:264 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},265 name="default" + str(number_of_app.times))266 print(default_app.name)267 number_of_app.times += 1268 ref = db.reference('Products').child(identity)269 ref.set({270 "name": name,271 "time": time,272 "state": state,273 "year": year,274 "date": date,275 "month": month,276 "image": self.product_image,277 "maximum": max,278 "minimum": min279 })280281 def get_img_url(self, cat):282 from connection_status import connect283 if connect():284 from firebase_admin import credentials, initialize_app, db285 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")286 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},287 name=cat + self.pic_name)288 store = db.reference("Categories_url", default_app).child(cat)289 stores = store.get()290 print("ok")291 self.amount = stores.values().__len__()292 for x in stores.values():293 for y in stores.keys():294 Upload_image.pic_url = x["url"]295 Upload_image.pic_name = y296297 def size_me(cat):298 from connection_status import connect299 if connect():300 content = + 1301 from firebase_admin import credentials, initialize_app, db302 cred = credentials.Certificate("farmzon-abdcb-c4c57249e43b.json")303 default_app = initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'},304 name=cat + str(content))305 store = db.reference("Categories_url", default_app).child(cat)306 stores = store.get()307 big = stores.values().__len__()308 return big309310# Upload_image.uploadima(Upload_image())311# Upload_image.put_in_database(Upload_image(), "wewe") ...

Full Screen

Full Screen

db_transf.py

Source:db_transf.py Github

copy

Full Screen

...17 firebase_admin._apps.clear()18 from firebase_admin import credentials, initialize_app, db19 if not firebase_admin._apps:20 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")21 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})22 print("Starting deployment....", int(phone))23 ref = db.reference('Shoppy').child('Users')24 users = ref.get()25 if phone in users:26 print('It there')27 else:28 ref = db.reference('Shoppy').child("Users").child(phone)29 print("horray!!!")30 ref.set(31 {32 'user_name': username,33 'phone': phone,34 'course': 'None',35 'date': self.date,36 'bio': 'more you buy more buying points',37 'logo': Fe.Logos(Fe(), username),38 'following': '0',39 'birth-date': 'None',40 })41 def Order(self, company, phone, location, quantity, amount, product_name, cate, product_id):42 if True:43 import firebase_admin44 firebase_admin._apps.clear()45 from firebase_admin import credentials, initialize_app, db46 if not firebase_admin._apps:47 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")48 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})49 self.orders_calc(company, product_name)50 self.current_time = str(datetime.datetime.now())51 self.date, self.time = self.current_time.strip().split()52 self.id_generator()53 ref = db.reference('Shoppy').child('Company').child(company).child("Orders").child(product_name). \54 child(self.order_id)55 ref.set({56 "company_phone": company,57 "Phone number": phone,58 "location": location,59 "quantity": quantity,60 "amount": amount,61 "oder_id": self.order_id,62 "product name": product_name,63 "time": self.time,64 "date": self.date65 })66 self.order_point(phone, amount)67 self.day_calc()68 refe = db.reference('Shoppy').child('Company').child(company).child("statistics"). \69 child(self.day).child(product_name)70 refe.set({71 "orders": self.orders72 })73 refp = db.reference('Shoppy').child("Users").child(phone).child('point')74 refp.set({75 "point": self.point76 })77 Fe.add_order(Fe(),self.order_id, amount, product_name, phone, self.date)78 self.bought_calc(cate, product_id, quantity)79 def orders_calc(self, company, name):80 if True:81 import firebase_admin82 firebase_admin._apps.clear()83 from firebase_admin import credentials, initialize_app, db84 if not firebase_admin._apps:85 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")86 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})87 print('now i am fuckn working')88 self.day_calc()89 try:90 print("Another way")91 ref = db.reference('Shoppy').child('Company').child(company).child('statistics').child(self.day).child(92 name).child('orders')93 self.orders = str(ref.get())94 self.orders = str(int(self.orders) + 1)95 print(self.orders)96 except:97 self.orders = '1'98 def bought_calc(self, cate, product_id, quantity):99 if True:100 import firebase_admin101 firebase_admin._apps.clear()102 from firebase_admin import credentials, initialize_app, db103 if not firebase_admin._apps:104 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")105 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})106 try:107 ref = db.reference('Shoppy').child('Products').child(cate).child(product_id).child('bought_times')108 self.bought = str(ref.get())109 self.bought = str(int(self.bought) + int(quantity))110 print(self.bought)111 ref.set(112 self.bought113 )114 except:115 print('Fail!')116 def add_loyal(self, phone, us_phn, usr_name):117 if True:118 import firebase_admin119 firebase_admin._apps.clear()120 from firebase_admin import credentials, initialize_app, db121 if not firebase_admin._apps:122 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")123 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})124 try:125 ref = db.reference('Shoppy').child('Company').child(phone).child('loyalties').child(us_phn)126 ref.set(127 {128 'user_number': us_phn,129 'user_name': usr_name130 }131 )132 refl = db.reference('Shoppy').child('Company').child(phone).child('followers')133 self.loyal = str(refl.get())134 self.loyal = str(int(self.loyal) + int(1))135 print(self.loyal)136 refl.set(137 self.loyal138 )139 return self.loyal140 except:141 print('Fail!')142 def order_point(self, phone, price):143 if True:144 import firebase_admin145 firebase_admin._apps.clear()146 from firebase_admin import credentials, initialize_app, db147 if not firebase_admin._apps:148 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")149 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})150 print('order fucker')151 try:152 print("fucking points")153 point = int(price) * (1 / 100)154 ref = db.reference('Shoppy').child("Users").child(phone).child('point')155 points = ref.get()156 self.point = int(points['point']) + point157 except:158 self.point = str(int(price) * (1 / 100))159 def day_calc(self):160 today = str(datetime.date.today())161 y, mon, day = today.strip().split("-")162 print(f'{y}-{mon}-{day}')163 time = f'{y}-{mon}-{day}'...

Full Screen

Full Screen

db_fetch.py

Source:db_fetch.py Github

copy

Full Screen

...16 from firebase_admin import credentials, initialize_app, db17 if not firebase_admin._apps:18 try:19 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")20 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})21 store = db.reference("Shoppy").child("Products").child(category)22 print("nice")23 stores = store.get()24 print("good")25 return stores26 except:27 return "No Internet!"28 def image_stiller(self, product_id, cate):29 image_list = []30 import firebase_admin31 firebase_admin._apps.clear()32 from firebase_admin import credentials, initialize_app, db33 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")34 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})35 store = db.reference("Shoppy").child("Products").child(cate)36 stores = store.get()37 for y, x in stores.items():38 if y == product_id:39 for c, v in x['images'].items():40 image_list.append(v['image_url'])41 print("getting", image_list)42 return image_list43 def company_stiller(self, phone):44 """45 bio:46 customer_name:47 customer_password:48 customer_phone:49 followers:50 following:51 logo:52 other_number:53 products::54 """55 import firebase_admin56 firebase_admin._apps.clear()57 from firebase_admin import credentials, initialize_app, db58 if not firebase_admin._apps:59 try:60 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")61 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})62 store = db.reference("Shoppy").child("Company").child(phone)63 print("nice")64 stores = store.get()65 return stores66 except:67 return "No Internet!"68 def company_products(self, phone):69 import firebase_admin70 firebase_admin._apps.clear()71 from firebase_admin import credentials, initialize_app, db72 if not firebase_admin._apps:73 try:74 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")75 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})76 store = db.reference("Shoppy").child("Company").child(phone).child('products')77 stores = store.get()78 print(stores)79 return stores80 except:81 return "No Internet!"82 def Profile(self, phone):83 """84 bio:85 course:86 date:87 logo:88 phone:89 user_name:90 """91 import firebase_admin92 firebase_admin._apps.clear()93 from firebase_admin import credentials, initialize_app, db94 if not firebase_admin._apps:95 try:96 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")97 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})98 store = db.reference("Shoppy").child("Users").child(phone)99 print("nice")100 stores = store.get()101 print(stores)102 return stores103 except:104 return "No Internet!"105 def add_order(self, p_id, price, p_name, phone, date):106 import json107 cached = {p_id: {'phone': phone,108 'price': price,109 'productName': p_name,110 'date': date}}111 self.data.append(cached)112 z = self.load()113 self.data.append(z)114 d = {k: v for x in self.data for k, v in x.items()}115 print(d)116 file = open('data/order.json', 'w')117 file.write(json.dumps(d))118 file.close()119 def load(self):120 try:121 file = open('data/order.json', 'r')122 data = json.load(file)123 return data124 except:125 data = {}126 return data127 def Logos(self, name):128 letter = str(name[0]).capitalize()129 import firebase_admin130 firebase_admin._apps.clear()131 from firebase_admin import credentials, initialize_app, db132 if not firebase_admin._apps:133 try:134 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")135 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})136 store = db.reference("Shoppy").child("Letters").child(letter).child('url')137 stores = store.get()138 print(stores)139 return stores140 except:141 print('No Internet!')142 return "No Internet!"143 def search(self, text):144 import firebase_admin145 firebase_admin._apps.clear()146 from firebase_admin import credentials, initialize_app, db147 if not firebase_admin._apps:148 try:149 cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")150 initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})151 store = db.reference("Shoppy").child("Company")152 text = text.capitalize()153 searched = store.order_by_child("customer_name").start_at(text).get()154 except:155 print('No Internet!')156 return "No Internet!"157 return searched158# Fetch.search(Fetch(),'a')159# Fetch.Logos(Fetch(), 'beast')160# x = Fetch.company_stiller(Fetch(), '0628834063')161# Fetch.company_products(Fetch(), '0687863886')162# Fetch.add_order(Fetch(), '00', '080', '9578', 'p[p[op', '090')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful