2017-03-15 16:43:43 +00:00
|
|
|
# ~*~ coding: utf-8 ~*~
|
2020-12-29 13:05:18 +00:00
|
|
|
import os
|
2021-01-19 06:36:41 +00:00
|
|
|
import uuid
|
2020-12-29 13:05:18 +00:00
|
|
|
|
2018-12-10 02:11:54 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2019-12-05 07:09:25 +00:00
|
|
|
|
2022-12-06 09:30:54 +00:00
|
|
|
from common.utils import get_logger, get_object_or_none, make_dirs
|
2020-12-16 09:31:30 +00:00
|
|
|
from orgs.utils import org_aware_func
|
2021-01-19 06:36:41 +00:00
|
|
|
from jumpserver.const import PROJECT_DIR
|
2020-03-12 08:24:38 +00:00
|
|
|
|
2022-12-05 07:03:21 +00:00
|
|
|
from .models import AdHoc, CeleryTask
|
2022-09-07 11:49:42 +00:00
|
|
|
from .const import DEFAULT_PASSWORD_RULES
|
2017-03-15 16:43:43 +00:00
|
|
|
|
|
|
|
logger = get_logger(__file__)
|
2017-12-06 10:31:51 +00:00
|
|
|
|
2017-12-22 13:42:12 +00:00
|
|
|
|
2020-12-29 13:05:18 +00:00
|
|
|
def get_task_log_path(base_path, task_id, level=2):
|
|
|
|
task_id = str(task_id)
|
2021-01-19 06:36:41 +00:00
|
|
|
try:
|
|
|
|
uuid.UUID(task_id)
|
|
|
|
except:
|
|
|
|
return os.path.join(PROJECT_DIR, 'data', 'caution.txt')
|
|
|
|
|
2020-12-29 13:05:18 +00:00
|
|
|
rel_path = os.path.join(*task_id[:level], task_id + '.log')
|
|
|
|
path = os.path.join(base_path, rel_path)
|
2022-10-18 09:47:13 +00:00
|
|
|
make_dirs(os.path.dirname(path), exist_ok=True)
|
2020-12-29 13:05:18 +00:00
|
|
|
return path
|
2022-09-07 11:49:42 +00:00
|
|
|
|