#! /usr/bin/env python import os, sys if os.environ.get("WL_MFA_USER"): os.system( f"""aws-mfa --duration 1800 --device arn:aws:iam::322697034778:mfa/{os.environ['WL_MFA_USER']}""" ) sys.path.append(".") from tracker import config from tracker.terminal_colors import colorise as __colorise, colors as __colors import IPython as __IPython __bar = """---------------------------------------------------""" __testing = """ ╔╦╗ ╔═╗ ╔═╗ ╔╦╗ ╦ ╔╗╔ ╔═╗ ║ ║╣ ╚═╗ ║ ║ ║║║ ║ ╦ ╩ ╚═╝ ╚═╝ ╩ ╩ ╝╚╝ ╚═╝ """ __production = """ ╔═╗╦═╗╔═╗╔╦╗╦ ╦╔═╗╔╦╗╦╔═╗╔╗╔ ╠═╝╠╦╝║ ║ ║║║ ║║ ║ ║║ ║║║║ ╩ ╩╚═╚═╝═╩╝╚═╝╚═╝ ╩ ╩╚═╝╝╚╝ """ __title = """ __ __ _ _ ___ _____ ___ _ ___ ___ ____ | | | | || |_ _|_ _| __| | |_ _/ __| _| \ \/\/ /| __ || | | | | _|| |_ | |\__ \| | \_/\_/_|_||_|___|SHELL ___|___|___|___/|_| """ __titles = "".join( [ "\n", __colorise(__bar, __colors.bold, __colors.fg.lightblue), "", __colorise(__title, __colors.bold, __colors.fg.lightblue), "\n", __colorise(__testing, __colors.bold, __colors.fg.green) if "localhost" in str(config.db_connection_uri) else __colorise(__production, __colors.bold, __colors.fg.red), "\n", __colorise(__bar, __colors.bold, __colors.fg.lightblue), "\n\n", ] ) from tracker.logger import setup_logging, get_logger setup_logging(for_console=True, default_level=config.api_logging_level) from tracker import db import scripts.scheduling as scheduling from importlib import reload from datetime import datetime, timedelta, date from sqlalchemy import or_, func import sqlalchemy as sa from tracker import utils from tracker.utils import a_datetime from scripts import user_management as um db.setup_session(echo=config.api_echo_statements, application_name="wipyt") scheduler = scheduling.init_scheduler() def deploy_candidate_api(): return os.system("./scripts/build_and_deploy_api_candidate.sh") __IPython.embed( header="".join( [ __titles, "Database at: ", __colorise( str(db.Session.get_bind().url).split("/")[-1], __colors.bold, __colors.fg.yellow, ), ("\n[echoing statements enabled]\n" if config.api_echo_statements else ""), "\n", "Available: ", __colorise( ", ".join( str(v) for v in vars().keys() if v not in ("In", "Out", "get_ipython", "exit", "quit") and not v.startswith("_") ), __colors.fg.yellow, ), "\n" "To create a new user use um.create_new_user?", ] ) )