from pathlib import Path from dotenv import load_dotenv env_path = Path('.') / '.env' load_dotenv(dotenv_path=env_path) from secrets_management.manage import decrypt_credentials, load_credentials, get_environment load_credentials(decrypt_credentials(which=['*.env'])) import asyncpg from datetime import timedelta from datetime import datetime from utils.timeseries.timescale_utils import init_db, init_connection, get_pool print("""=== Timescale REPL Loaded === To load TimescaleDB connection: pool = await get_pool() conn = await pool.acquire() await conn.fetch(query, *params) """)
from ticker.main_loop import Ticker if get_environment() == "development": import ptvsd print("[Scheduler] debug mode") try: ptvsd.enable_attach(address=("0.0.0.0", 5680)) ptvsd.wait_for_attach(8) except Exception as e: print(e) print("[Scheduler] ptvsd attach aborted") load_credentials(decrypt_credentials(which=["*.env"])) app = web.Application() db_middleware = init_middleware(app) app.middlewares.append(db_middleware) async def persistent_session(app): app["PERSISTENT_SESSION"] = session = aiohttp.ClientSession() yield await session.close() app.cleanup_ctx.append(persistent_session) ticker = Ticker()
def cli(env): print(f'Encrypting env: {env}...') encrypt_credentials(env) print(f'Test loading env: {env}...') load_credentials(decrypt_credentials(env, which=['*.env'])) print('Done.')
def main(): load_credentials(decrypt_credentials(which=["*.env"])) asyncio.get_event_loop().run_until_complete(test_asyncpg())
def process_init(): print(f"[init] Starting process for environment `{get_environment()}`") load_credentials(decrypt_credentials(which=["*.env"])) print("[init] Initializing middlewares...")
def cli(env): print(f"Encrypting env: {env}...") encrypt_credentials(env) print(f"Test loading env: {env}...") load_credentials(decrypt_credentials(env, which=["*.env"])) print("Done.")