From b684732836e371c591f0b513284a21827426abeb Mon Sep 17 00:00:00 2001 From: Pavel Kirilin <win10@list.ru> Date: Mon, 15 Jul 2024 00:30:37 +0200 Subject: [PATCH] Added more env params. Signed-off-by: Pavel Kirilin <win10@list.ru> --- autotex/__main__.py | 10 ++++------ autotex/settings.py | 8 ++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 autotex/settings.py diff --git a/autotex/__main__.py b/autotex/__main__.py index a064e87..825dc08 100644 --- a/autotex/__main__.py +++ b/autotex/__main__.py @@ -7,10 +7,8 @@ import tempfile from aiogram import Bot, Dispatcher, types import shutil -import os -import dotenv +from autotex import settings -dotenv.load_dotenv() pdftex_bin = shutil.which("pdflatex") magick_bin = shutil.which("magick") @@ -21,7 +19,7 @@ if magick_bin is None: raise ValueError("ImageMagick is not installed") dp = Dispatcher() -bot = Bot(token=os.environ["BOT_TOKEN"]) +bot = Bot(token=settings.BOT_TOKEN) PREAMBULA = """\ @@ -78,10 +76,10 @@ async def send_latex(message: types.Message) -> None: magick_bin, # type: ignore "convert", "-density", - "300", + str(settings.IMAGE_DPI), f"{name}.pdf", "-quality", - "100", + str(settings.IMAGE_QUALITY), f"{name}.jpg", cwd=cwd, stdout=asyncio.subprocess.PIPE, diff --git a/autotex/settings.py b/autotex/settings.py new file mode 100644 index 0000000..0d937f6 --- /dev/null +++ b/autotex/settings.py @@ -0,0 +1,8 @@ +import os +import dotenv + +dotenv.load_dotenv() + +BOT_TOKEN = os.environ["BOT_TOKEN"] +IMAGE_DPI = int(os.environ.get("IMAGE_DPI", 300)) +IMAGE_QUALITY = int(os.environ.get("IMAGE_QUALITY", 100)) -- GitLab