mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 02:59:27 +00:00
moved imports so logrotate does not run when singleton detection detects other instance
This commit is contained in:
26
builder.py
26
builder.py
@@ -12,10 +12,7 @@ from pathlib import Path
|
|||||||
from tqdm.auto import tqdm
|
from tqdm.auto import tqdm
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
|
|
||||||
from modules.logger import logger
|
|
||||||
from modules.argumentparser import parse_arguments, Args
|
from modules.argumentparser import parse_arguments, Args
|
||||||
from modules.svg_handling import icons, webmanifest, extract_colorscheme
|
|
||||||
from modules.generate_html import list_folder, EXCLUDES
|
|
||||||
|
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
@@ -39,6 +36,17 @@ NOT_LIST = ["*/Galleries/*", "Archives"]
|
|||||||
|
|
||||||
pbardict: dict[str, tqdm] = {}
|
pbardict: dict[str, tqdm] = {}
|
||||||
|
|
||||||
|
args = parse_arguments(VERSION)
|
||||||
|
|
||||||
|
lock_file = os.path.join(args.root_directory, ".lock")
|
||||||
|
if os.path.exists(lock_file):
|
||||||
|
print("Another instance of this program is running.")
|
||||||
|
sys.exit()
|
||||||
|
else:
|
||||||
|
from modules.logger import logger
|
||||||
|
from modules.svg_handling import icons, webmanifest, extract_colorscheme
|
||||||
|
from modules.generate_html import list_folder, EXCLUDES
|
||||||
|
|
||||||
|
|
||||||
def init_globals(_args: Args, raw: list[str]) -> tuple[Args, list[str]]:
|
def init_globals(_args: Args, raw: list[str]) -> tuple[Args, list[str]]:
|
||||||
"""
|
"""
|
||||||
@@ -184,20 +192,14 @@ def get_total_folders(folder: str, _args: Args, _total: int = 0) -> int:
|
|||||||
return _total
|
return _total
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main(args) -> None:
|
||||||
"""
|
"""
|
||||||
Main function to process images and generate a static image hosting website.
|
Main function to process images and generate a static image hosting website.
|
||||||
"""
|
"""
|
||||||
thumbnails: list[tuple[str, str, str, bool]] = []
|
thumbnails: list[tuple[str, str, str, bool]] = []
|
||||||
|
|
||||||
args = parse_arguments(VERSION)
|
|
||||||
args, raw = init_globals(args, RAW_EXTENSIONS)
|
args, raw = init_globals(args, RAW_EXTENSIONS)
|
||||||
|
|
||||||
lock_file = os.path.join(args.root_directory, ".lock")
|
|
||||||
if os.path.exists(lock_file):
|
|
||||||
print("Another instance of this program is running.")
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Path(lock_file).touch()
|
Path(lock_file).touch()
|
||||||
logger.info("starting builder", extra={"version": VERSION})
|
logger.info("starting builder", extra={"version": VERSION})
|
||||||
@@ -212,7 +214,7 @@ def main() -> None:
|
|||||||
if logo.startswith("<!--"):
|
if logo.startswith("<!--"):
|
||||||
logo = re.sub(r"<!--.+-->", "", logo).strip()
|
logo = re.sub(r"<!--.+-->", "", logo).strip()
|
||||||
logo = logo.replace("\n", " ")
|
logo = logo.replace("\n", " ")
|
||||||
logo = ' '.join(logo.split())
|
logo = " ".join(logo.split())
|
||||||
|
|
||||||
if args.reread_metadata:
|
if args.reread_metadata:
|
||||||
logger.warning("reread metadata flag is set to true, all image metadata will be reread")
|
logger.warning("reread metadata flag is set to true, all image metadata will be reread")
|
||||||
@@ -266,4 +268,4 @@ def main() -> None:
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
freeze_support()
|
freeze_support()
|
||||||
main()
|
main(args)
|
||||||
|
|||||||
Reference in New Issue
Block a user