final commit before first prod test

This commit is contained in:
C committed 2026-01-07 09:59:36 -08:00
1 parent a6e2397046
commit dbe5cd6146
4 files changed
+12 -4

No files matched your search

+1
View File
@@ -91,6 +91,7 @@ def when_ready(server):
print("\n".join(banner_lines)) print("\n".join(banner_lines))
print("Built for PLAY-WELL TEKNOLOGIES by contact@studspider.sh\n\n") 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"HOST:\t{bind}")
print(f"WORKERS:\t{workers}") print(f"WORKERS:\t{workers}")
print(f"WORKER TYPE:\t{worker_class}") print(f"WORKER TYPE:\t{worker_class}")
+4 -2
View File
@@ -13,6 +13,7 @@ from typing import Dict, Any, Optional
from datetime import datetime, timedelta from datetime import datetime, timedelta
from async_lru import alru_cache from async_lru import alru_cache
from . import throttler from . import throttler
from . import get_sq_env
Throttler = throttler.GlobalThrottler Throttler = throttler.GlobalThrottler
@@ -22,11 +23,12 @@ dotenv.load_dotenv()
class AsyncBricksetAPI: class AsyncBricksetAPI:
"""Asynchronous client for the Brickset API""" """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.username = os.getenv("BRICKSET_USERNAME")
self.password = os.getenv("BRICKSET_PASS") self.password = os.getenv("BRICKSET_PASS")
self.api_key = os.getenv("BRICKSET_API_KEY") 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.headers = {"UserAgent": "studspider/0.1"}
self.throttler = Throttler(rate_limit=500, period=60) self.throttler = Throttler(rate_limit=500, period=60)
self.user_hash = None self.user_hash = None
+5 -1
View File
@@ -11,7 +11,11 @@ LEGO_CAT_ID = os.getenv("SQUARE_LEGO_CAT_ID")
SQUARE_WEBHOOK_URL = os.getenv("SQUARE_WEBHOOK_URL") 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_APP_ID = os.getenv("PROD_SQUARE_APP_ID")
SQUARE_TOKEN = os.getenv("PROD_SQUARE_TOKEN") SQUARE_TOKEN = os.getenv("PROD_SQUARE_TOKEN")
SQUARE_WEBHOOK_SIGNATURE_KEY = os.getenv("PROD_SQUARE_WEBHOOK_SIGNATURE_KEY") SQUARE_WEBHOOK_SIGNATURE_KEY = os.getenv("PROD_SQUARE_WEBHOOK_SIGNATURE_KEY")
+2 -1
View File
@@ -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}") print(f"[@DEBUG] Extracted set number: {set_number}")
# Fetch Brickset data (with throttling) # 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) lego_set = await brickset_client.throttled_get_set(set_number)
if logger: if logger: