Best Python code snippet using localstack_python
payment_source_checker.py
Source:payment_source_checker.py
1import requests2from requests.api import head3from requests.models import parse_url45tokenlist_r = open("token_list.txt", "r")6tokenlist = tokenlist_r.readlines()78for current_token in tokenlist:9 token = current_token.rstrip("\n")10 headers = {"Authorization": token}11 check_payment_sources = requests.get('https://discord.com/api/v9/users/@me/billing/payment-sources', headers=headers)12 if '''"invalid": false''' in check_payment_sources.text:13 output = open("has_payment_source.txt", "a")14 output.write("----------------------------------------\n")15 output.write(f"Valid: {token}\n")16 output.write("----------------------------------------\n")17 output.close()18 check_subscription = requests.get('https://discord.com/api/v9/users/@me/billing/subscriptions', headers=headers)19 if check_subscription.status_code == '200' and check_subscription.text == '[]':20 pass21 else:22 output = open("has_subscription.txt", "a")23 output.write("----------------------------------------\n")24 output.write(f"Valid: {token}\n")25 output.write("----------------------------------------\n")
...
tasks.py
Source:tasks.py
...25@app.task26def check_promotion():27 return Promotion.objects.filter(finished__lte=date.today()).delete()28@app.task29def check_subscription():30 users_with_subscription = User.objects.filter(subscribed=True,31 end_date=date.today())32 for user in users_with_subscription:33 user.subscribed = False...
checker.py
Source:checker.py
1import requests2from requests.api import head3from requests.models import parse_url4tokenlist_r = open("token.txt", "r")5tokenlist = tokenlist_r.readlines()6for current_token in tokenlist:7 token = current_token.rstrip("\n")8 headers = {"Authorization": token}9 check_payment_sources = requests.get('https://discord.com/api/v9/users/@me/billing/payment-sources', headers=headers)10 if '''"invalid": false''' in check_payment_sources.text:11 output = open("payment.txt", "a")12 output.write(f"Valid: {token}\n")13 output.close()14 check_subscription = requests.get('https://discord.com/api/v9/users/@me/billing/subscriptions', headers=headers)15 if check_subscription.status_code == '200' and check_subscription.text == '[]':16 pass17 else:18 output = open("subscription.txt", "a")19 output.write(f"Valid: {token}\n")...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!