remove "with app.app_context():"
This commit is contained in:
parent
074dd875dc
commit
eb0e327402
3
cron.py
3
cron.py
|
@ -849,9 +849,6 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
app = create_app()
|
|
||||||
|
|
||||||
with app.app_context():
|
|
||||||
if args.job == "stats":
|
if args.job == "stats":
|
||||||
LOG.d("Compute Stats")
|
LOG.d("Compute Stats")
|
||||||
stats()
|
stats()
|
||||||
|
|
|
@ -1986,8 +1986,6 @@ def main(port: int):
|
||||||
|
|
||||||
if LOAD_PGP_EMAIL_HANDLER:
|
if LOAD_PGP_EMAIL_HANDLER:
|
||||||
LOG.w("LOAD PGP keys")
|
LOG.w("LOAD PGP keys")
|
||||||
app = create_app()
|
|
||||||
with app.app_context():
|
|
||||||
load_pgp_public_keys()
|
load_pgp_public_keys()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -51,8 +51,5 @@ def add_sl_domains():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = create_app()
|
|
||||||
|
|
||||||
with app.app_context():
|
|
||||||
load_pgp_public_keys()
|
load_pgp_public_keys()
|
||||||
add_sl_domains()
|
add_sl_domains()
|
||||||
|
|
|
@ -103,9 +103,6 @@ if __name__ == "__main__":
|
||||||
min_dt = arrow.now().shift(hours=-1)
|
min_dt = arrow.now().shift(hours=-1)
|
||||||
max_dt = arrow.now().shift(hours=1)
|
max_dt = arrow.now().shift(hours=1)
|
||||||
|
|
||||||
app = new_app()
|
|
||||||
|
|
||||||
with app.app_context():
|
|
||||||
for job in Job.filter(
|
for job in Job.filter(
|
||||||
Job.taken.is_(False), Job.run_at > min_dt, Job.run_at <= max_dt
|
Job.taken.is_(False), Job.run_at > min_dt, Job.run_at <= max_dt
|
||||||
).all():
|
).all():
|
||||||
|
|
|
@ -59,8 +59,6 @@ def nb_files(directory) -> int:
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
while True:
|
while True:
|
||||||
app = create_app()
|
|
||||||
with app.app_context():
|
|
||||||
get_stats()
|
get_stats()
|
||||||
|
|
||||||
# 1 min
|
# 1 min
|
||||||
|
|
|
@ -924,7 +924,6 @@ def register_custom_commands(app):
|
||||||
from init_app import add_sl_domains
|
from init_app import add_sl_domains
|
||||||
|
|
||||||
LOG.w("reset db, add fake data")
|
LOG.w("reset db, add fake data")
|
||||||
with app.app_context():
|
|
||||||
fake_data()
|
fake_data()
|
||||||
add_sl_domains()
|
add_sl_domains()
|
||||||
|
|
||||||
|
|
4
shell.py
4
shell.py
|
@ -137,9 +137,7 @@ def send_onboarding_emails(user):
|
||||||
onboarding_pgp(user)
|
onboarding_pgp(user)
|
||||||
|
|
||||||
|
|
||||||
app = create_app()
|
if __name__ == "__main__":
|
||||||
|
|
||||||
with app.app_context():
|
|
||||||
# to test email template
|
# to test email template
|
||||||
# with open("/tmp/email.html", "w") as f:
|
# with open("/tmp/email.html", "w") as f:
|
||||||
# user = User.first()
|
# user = User.first()
|
||||||
|
|
|
@ -24,7 +24,6 @@ app.config["TESTING"] = True
|
||||||
app.config["WTF_CSRF_ENABLED"] = False
|
app.config["WTF_CSRF_ENABLED"] = False
|
||||||
app.config["SERVER_NAME"] = "sl.test"
|
app.config["SERVER_NAME"] = "sl.test"
|
||||||
|
|
||||||
with app.app_context():
|
|
||||||
# enable pg_trgm extension
|
# enable pg_trgm extension
|
||||||
with engine.connect() as conn:
|
with engine.connect() as conn:
|
||||||
try:
|
try:
|
||||||
|
@ -49,7 +48,6 @@ def flask_app():
|
||||||
def flask_client():
|
def flask_client():
|
||||||
transaction = connection.begin()
|
transaction = connection.begin()
|
||||||
|
|
||||||
with app.app_context():
|
|
||||||
try:
|
try:
|
||||||
client = app.test_client()
|
client = app.test_client()
|
||||||
yield client
|
yield client
|
||||||
|
|
Loading…
Reference in a new issue