mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Update job initialization in jobs.py to avoid issues with frames
This commit is contained in:
parent
fbabbbd8d6
commit
b1707d5efe
1 changed files with 7 additions and 3 deletions
|
|
@ -2,14 +2,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from inspect import getsourcefile
|
||||
from io import BytesIO
|
||||
from logging import Logger
|
||||
from os import getenv
|
||||
from os.path import sep
|
||||
from pathlib import Path
|
||||
from shutil import rmtree
|
||||
from sys import _getframe
|
||||
from sys import argv
|
||||
from tarfile import open as tar_open
|
||||
from threading import Lock
|
||||
from traceback import format_exc
|
||||
|
|
@ -28,11 +27,16 @@ EXPIRE_TIME = {
|
|||
|
||||
class Job:
|
||||
def __init__(self, logger: Optional[Logger] = None, db=None, *, job_name: str = "", deprecated: bool = False):
|
||||
source_file = getsourcefile(_getframe(1))
|
||||
if not argv:
|
||||
raise ValueError("argv could not be determined.")
|
||||
|
||||
source_file = argv[0]
|
||||
|
||||
if source_file is None:
|
||||
raise ValueError("source_file could not be determined.")
|
||||
elif not logger and not db:
|
||||
raise ValueError("Either logger or db must be provided.")
|
||||
|
||||
source_path = Path(source_file)
|
||||
self.job_path = Path(sep, "var", "cache", "bunkerweb", source_path.parent.parent.name)
|
||||
self.job_name = job_name or source_path.name.replace(".py", "")
|
||||
|
|
|
|||
Loading…
Reference in a new issue