final commit before first prod test
This commit is contained in:
1 parent
a6e2397046
commit
dbe5cd6146
4 files changed
+12
-4
No files matched your search
@@ -91,6 +91,7 @@ def when_ready(server):
|
||||
|
||||
print("\n".join(banner_lines))
|
||||
print("Built for PLAY-WELL TEKNOLOGIES by contact@studspider.sh\n\n")
|
||||
print("PRODUCTION MODE\n" if os.getenv("SQUARE_ENV") == "production" else "SANDBOX MODE\n")
|
||||
print(f"HOST:\t{bind}")
|
||||
print(f"WORKERS:\t{workers}")
|
||||
print(f"WORKER TYPE:\t{worker_class}")
|
||||
|
||||
+4
-2
@@ -13,6 +13,7 @@ from typing import Dict, Any, Optional
|
||||
from datetime import datetime, timedelta
|
||||
from async_lru import alru_cache
|
||||
from . import throttler
|
||||
from . import get_sq_env
|
||||
|
||||
Throttler = throttler.GlobalThrottler
|
||||
|
||||
@@ -22,11 +23,12 @@ dotenv.load_dotenv()
|
||||
class AsyncBricksetAPI:
|
||||
"""Asynchronous client for the Brickset API"""
|
||||
|
||||
def __init__(self, debug: bool = False, logger=None):
|
||||
def __init__(self, debug: bool = None, logger=None):
|
||||
self.username = os.getenv("BRICKSET_USERNAME")
|
||||
self.password = os.getenv("BRICKSET_PASS")
|
||||
self.api_key = os.getenv("BRICKSET_API_KEY")
|
||||
self.debug = debug
|
||||
# Use DEBUG_MODE from env if debug not explicitly set
|
||||
self.debug = debug if debug is not None else get_sq_env.DEBUG_MODE
|
||||
self.headers = {"UserAgent": "studspider/0.1"}
|
||||
self.throttler = Throttler(rate_limit=500, period=60)
|
||||
self.user_hash = None
|
||||
|
||||
+5
-1
@@ -11,7 +11,11 @@ LEGO_CAT_ID = os.getenv("SQUARE_LEGO_CAT_ID")
|
||||
|
||||
SQUARE_WEBHOOK_URL = os.getenv("SQUARE_WEBHOOK_URL")
|
||||
|
||||
if os.getenv("SQUARE_ENV") == "production":
|
||||
# Check environment mode
|
||||
IS_PRODUCTION = os.getenv("SQUARE_ENV") == "production"
|
||||
DEBUG_MODE = not IS_PRODUCTION # Debug logging enabled in sandbox/dev
|
||||
|
||||
if IS_PRODUCTION:
|
||||
SQUARE_APP_ID = os.getenv("PROD_SQUARE_APP_ID")
|
||||
SQUARE_TOKEN = os.getenv("PROD_SQUARE_TOKEN")
|
||||
SQUARE_WEBHOOK_SIGNATURE_KEY = os.getenv("PROD_SQUARE_WEBHOOK_SIGNATURE_KEY")
|
||||
|
||||
+2
-1
@@ -96,7 +96,8 @@ async def enrich_single_item(item_id: str, item_data: dict = None, logger=None)
|
||||
print(f"[@DEBUG] Extracted set number: {set_number}")
|
||||
|
||||
# Fetch Brickset data (with throttling)
|
||||
brickset_client = abricksetapi.AsyncBricksetAPI(debug=True, logger=logger)
|
||||
# debug flag will be auto-set based on SQUARE_ENV
|
||||
brickset_client = abricksetapi.AsyncBricksetAPI(logger=logger)
|
||||
lego_set = await brickset_client.throttled_get_set(set_number)
|
||||
|
||||
if logger:
|
||||
|
||||
Reference in new issue
Block a user