From 8faf56f9ad93f86b4191429b2e6a30e2e1ae0338 Mon Sep 17 00:00:00 2001 From: C <0xicl33n@gmail.com> Date: Sun, 12 Oct 2025 11:51:49 -0700 Subject: [PATCH] time stuff --- src/glue.py | 9 +++++++-- src/test_server.py | 17 +++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/glue.py b/src/glue.py index db53fc8..f52eb01 100644 --- a/src/glue.py +++ b/src/glue.py @@ -1,15 +1,20 @@ import asyncio import json +import re import get_sq_env import aiosqlite +from time import time import asquare import db import abricksetapi -from . throttler import GlobalThrottler +from throttler import GlobalThrottler +LEGO_CAT_ID = get_sq_env.LEGO_CAT_ID + +# big glue boy async def do_review() -> bool: - result = await asquare.acat2id(LEGO_CAT_ID) + result = await asquare.acat2id(LEGO_CAT_ID) # type: ignore for item in result: if not re.match(r".*\d{5}.*", item["name"]): missing = [] diff --git a/src/test_server.py b/src/test_server.py index e378d42..cbae6df 100644 --- a/src/test_server.py +++ b/src/test_server.py @@ -4,19 +4,20 @@ from aiohttp import web from base64 import b64decode from typing import Dict, Any import uuid -from time import time + import dotenv import os import re import logging from logging.handlers import RotatingFileHandler from pathlib import Path -#print("Creating log directory if it doesn't exist...") -#Path("./logs/").mkdir(parents=True, exist_ok=True) +print("Creating log directory if it doesn't exist...") +os.makedirs("./logs/", exist_ok=True) import banner import get_sq_env - +from time import time +time = int(time()) import asquare as sq # from asquareclass import AsyncSquareClient # type: ignore @@ -46,7 +47,7 @@ UA = re.compile(r"^kopling\/?", re.IGNORECASE) async def run_update(): - set_list = await sq.acat2id(SQUARE_LEGO_CAT_ID) + set_list = await sq.acat2id(SQUARE_LEGO_CAT_ID) # type: ignore #print(f"[@DEBUG]\t {set_list}") # type: ignore for l_set in set_list: #print(f"[@DEBUG]{l_set}") @@ -85,7 +86,7 @@ async def request_handler(request: web.Request) -> web.Response: # Verify request method if request.method != "POST": logger.error( - f"{time()}\tInvalid request method from %s at ", request.remote + f"{time}\tInvalid request method from %s at ", request.remote ) return web.Response(status=405, text="Method not allowed. Use POST.") @@ -114,10 +115,10 @@ async def request_handler(request: web.Request) -> web.Response: try: decoded_cmd = b64decode(data["CMD"]).decode("utf-8") print( - f"""At: {time()}\nReceived command: {decoded_cmd}\nUser-Agent: {request.headers.get('User-Agent')}\nIdempotency-Key: {request.headers.get('Idempotency-Key')}""" + f"""At: {time}\nReceived command: {decoded_cmd}\nUser-Agent: {request.headers.get('User-Agent')}\nIdempotency-Key: {request.headers.get('Idempotency-Key')}""" ) logging.info( - f"{time()}\tCommand: {decoded_cmd}\tFrom: {request.remote}\tUA: {request.headers.get('User-Agent')}\tIdempotency-Key: {request.headers.get('Idempotency-Key')}" + f"{time}\tCommand: {decoded_cmd}\tFrom: {request.remote}\tUA: {request.headers.get('User-Agent')}\tIdempotency-Key: {request.headers.get('Idempotency-Key')}" ) # Process the command