From 6a140e7cac0481f2aacae2da6a43f946f9581f72 Mon Sep 17 00:00:00 2001 From: kompotkot Date: Wed, 17 Aug 2022 14:50:47 +0000 Subject: [PATCH] Naming and try catch for moonstream bugout client api call --- crawlers/mooncrawl/mooncrawl/settings.py | 10 ++++++++-- crawlers/mooncrawl/sample.env | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crawlers/mooncrawl/mooncrawl/settings.py b/crawlers/mooncrawl/mooncrawl/settings.py index b90a12bf..dc355d4a 100644 --- a/crawlers/mooncrawl/mooncrawl/settings.py +++ b/crawlers/mooncrawl/mooncrawl/settings.py @@ -13,9 +13,15 @@ BUGOUT_BROOD_URL = os.environ.get("BUGOUT_BROOD_URL", "https://auth.bugout.dev") BUGOUT_SPIRE_URL = os.environ.get("BUGOUT_SPIRE_URL", "https://spire.bugout.dev") bugout_client = Bugout(brood_api_url=BUGOUT_BROOD_URL, spire_api_url=BUGOUT_SPIRE_URL) -BUGOUT_REQUEST_TIMEOUT_SECONDS = int( - os.environ.get("BUGOUT_REQUEST_TIMEOUT_SECONDS", "30") +BUGOUT_REQUEST_TIMEOUT_SECONDS_RAW = os.environ.get( + "MOONSTREAM_BUGOUT_TIMEOUT_SECONDS", 30 ) +try: + BUGOUT_TIMEOUT_SECONDS = int(BUGOUT_REQUEST_TIMEOUT_SECONDS_RAW) +except: + raise Exception( + f"Could not parse MOONSTREAM_BUGOUT_TIMEOUT_SECONDS_RAW as int: {BUGOUT_REQUEST_TIMEOUT_SECONDS_RAW}" + ) HUMBUG_REPORTER_CRAWLERS_TOKEN = os.environ.get("HUMBUG_REPORTER_CRAWLERS_TOKEN") diff --git a/crawlers/mooncrawl/sample.env b/crawlers/mooncrawl/sample.env index 5039ae09..23ee4108 100644 --- a/crawlers/mooncrawl/sample.env +++ b/crawlers/mooncrawl/sample.env @@ -1,10 +1,10 @@ # Bugout environment variables export BUGOUT_BROOD_URL="https://auth.bugout.dev" export BUGOUT_SPIRE_URL="https://spire.bugout.dev" -export BUGOUT_REQUEST_TIMEOUT_SECONDS=30 export HUMBUG_REPORTER_CRAWLERS_TOKEN="" # Moonstream environment variables +export MOONSTREAM_BUGOUT_TIMEOUT_SECONDS=30 export MOONSTREAM_CORS_ALLOWED_ORIGINS="http://localhost:3000,https://moonstream.to,https://www.moonstream.to" export MOONSTREAM_DB_URI="postgresql://:@:/" export MOONSTREAM_DB_URI_READ_ONLY="postgresql://:@:/"