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
|
2023-07-17 05:59:45 +00:00
|
|
|
from django.conf import settings
|
2020-12-29 13:05:18 +00:00
|
|
|
|
2023-07-17 05:59:45 +00:00
|
|
|
from common.utils import get_logger, make_dirs
|
2021-01-19 06:36:41 +00:00
|
|
|
from jumpserver.const import PROJECT_DIR
|
2020-03-12 08:24:38 +00:00
|
|
|
|
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
|
|
|
|
2023-07-17 05:59:45 +00:00
|
|
|
|
|
|
|
def get_ansible_log_verbosity(verbosity=0):
|
|
|
|
if settings.DEBUG_ANSIBLE:
|
|
|
|
return 10
|
|
|
|
if verbosity is None and settings.DEBUG:
|
|
|
|
return 1
|
|
|
|
return verbosity
|
|
|
|
|