This commit is contained in:
2026-02-10 18:12:52 +00:00
parent 91b3740ec0
commit dc34a78e06
7 changed files with 13 additions and 85 deletions

View File

@ -25,17 +25,9 @@ RUN \
else echo "Lockfile not found." && exit 1; \
fi
FROM python:3.13 AS runner
FROM python:3.14 AS runner
LABEL maintainer="Amritanshu <docker@tanshu.com>"
RUN apt-get update && \
apt-get install -y locales && \
sed --in-place --expression='s/# en_IN UTF-8/en_IN UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales
ENV LANG=en_IN
ENV LC_ALL=en_IN
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python - && \
cd /usr/local/bin && \

View File

@ -99,7 +99,9 @@ def save(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="Not enough bundle items.",
)
sale_price = round(sum(round(it.sale_price, 2) * round(it.quantity, 5) for it in data.items), 2)
sale_price = round(
sum((round(it.sale_price, 2) * round(it.quantity, 5) for it in data.items), start=Decimal(0)), 2
)
product = Product(sort_order=data.sort_order)
db.add(product)
@ -174,7 +176,9 @@ def update_route(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="Not enough bundle items.",
)
sale_price = round(sum(round(it.sale_price, 2) * round(it.quantity, 5) for it in data.items), 2)
sale_price = round(
sum((round(it.sale_price, 2) * round(it.quantity, 5) for it in data.items), start=Decimal(0)), 2
)
# Load header SKU + active header SkuVersion + menu category + product + active ProductVersion
sv: SkuVersion | None = (
db.execute(

View File

@ -1,33 +0,0 @@
import re # noqa: F401
import socket # noqa: F401
import sys # noqa: F401
from arq import Retry
async def sent_to_printer(ctx: dict, data: str, address: str, cut_code: str):
print(ctx, data, address, cut_code)
try:
with open(address, "w") as printer:
printer.write(data)
printer.write("\n")
print(cut_code)
printer.write(cut_code)
except LookupError as e:
print("Lookup error:", e)
except: # noqa: E722
print("Unexpected error:", sys.exc_info()[0])
# retry the job with increasing back-off
# delays will be 5s, 10s, 15s, 20s
# after max_tries (default 5) the job will permanently fail
raise Retry(defer=ctx["job_try"] * 5) from None
# GS = "\x1d"
# PAPER_CUT = GS + "V"
# # For the printer ESC/POS Reference
# # https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=87
# # The m codes are in decimal and can be converted using the following table
# # https://www.eso.org/~ndelmott/ascii.html
# # The \x03 in all the following is to feed 3 lines before cut it can be increased or reduced
# FUNCTION_B_FULL_CUT = "\x41\x03"
# FUNCTION_B_PARTIAL_CUT = "\x42\x03"

View File

@ -1,35 +0,0 @@
import sys
from aiohttp import ClientSession
from barker.core.arq import settings
from barker.core.config import settings as sett
from barker.tasks.printing import sent_to_printer
sys.path.extend(["./"])
async def startup(ctx):
ctx["session"] = ClientSession()
print(f"Worker listening for: {sett.WORKER_QUEUE_NAME}")
# print(f"Worker printing on: {sett.WORKER_PRINTER_ADDRESS}")
async def shutdown(ctx):
await ctx["session"].close()
class WorkerSettings:
"""
Settings for the ARQ worker.
"""
queue_name = f"barker:print:{sett.WORKER_QUEUE_NAME}"
redis_settings = settings
functions: list = [sent_to_printer]
on_startup = startup
on_shutdown = shutdown
# command to run arq barker.worker.WorkerSettings

View File

@ -124,5 +124,10 @@ disallow_subclassing_any = true
disallow_untyped_defs = true
disallow_untyped_decorators = true
plugins = ["sqlalchemy.ext.mypy.plugin"]
plugins = ["sqlalchemy.ext.mypy.plugin", "pydantic.mypy"]
# --strict end
[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true

View File

@ -1,5 +0,0 @@
#! /usr/bin/env bash
set -e
echo arq barker.worker.WorkerSettings
arq barker.worker.WorkerSettings