# Path: teuthology/config.py
# def init_logging():
#     def __init__(self, yaml_path=None):
#     def load(self, conf=None):
#     def update(self, in_dict):
#     def from_dict(cls, in_dict):
#     def to_dict(self):
#     def from_str(cls, in_str):
#     def to_str(self):
#     def get(self, key, default=None):
#     def __str__(self):
#     def __repr__(self):
#     def __getitem__(self, name):
#     def __getattr__(self, name):
#     def __contains__(self, name):
#     def __setattr__(self, name, value):
#     def __delattr__(self, name):
#     def __len__(self):
#     def __iter__(self):
#     def __setitem__(self, name, value):
#     def __delitem__(self, name):
#     def __init__(self, yaml_path=None):
#     def get_ceph_cm_ansible_git_url(self):
#     def get_ceph_qa_suite_git_url(self):
#     def get_ceph_git_url(self):
#     def __init__(self, config_dict=None):
#     def _clean_config(self, config_dict):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def __repr__(self):
#     def __str__(self):
# def set_config_attr(obj):
# def _get_config_path():
# class YamlConfig(collections.MutableMapping):
# class TeuthologyConfig(YamlConfig):
# class JobConfig(YamlConfig):
# class FakeNamespace(YamlConfig):
# 
# Path: teuthology/misc.py
# def get_http_log_path(archive_dir, job_id=None):
#     """
#     :param archive_dir: directory to be searched
#     :param job_id: id of job that terminates the name of the log path
#     :returns: http log path
#     """
#     http_base = config.archive_server
#     if not http_base:
#         return None
# 
#     sep = os.path.sep
#     archive_dir = archive_dir.rstrip(sep)
#     archive_subdir = archive_dir.split(sep)[-1]
#     if archive_subdir.endswith(str(job_id)):
#         archive_subdir = archive_dir.split(sep)[-2]
# 
#     if job_id is None:
#         return os.path.join(http_base, archive_subdir, '')
#     return os.path.join(http_base, archive_subdir, str(job_id), '')
# 
# def get_results_url(run_name, job_id=None):
#     """
#     :param run_name: The name of the test run
#     :param job_id: The job_id of the job. Optional.
#     :returns: URL to the run (or job, if job_id is passed) in the results web
#               UI. For example, Inktank uses Pulpito.
#     """
#     if not config.results_ui_server:
#         return None
#     base_url = config.results_ui_server
# 
#     if job_id is None:
#         return os.path.join(base_url, run_name, '')
#     return os.path.join(base_url, run_name, str(job_id), '')


import jinja2
import logging
import os
import sys
import time
import types
import yaml
import sentry_sdk
    import smtplib
from copy import deepcopy
from humanfriendly import format_timespan
from teuthology.config import config as teuth_config
from teuthology.exceptions import ConnectionLostError
from teuthology.job_status import set_status, get_status
from teuthology.misc import get_http_log_path, get_results_url
from teuthology.timer import Timer
            from teuthology.task import interactive
                        from teuthology.task import interactive
        from rocketchat.api import RocketChatAPI
    from email.mime.text import MIMEText
            del exc_info
        timer.mark("tasks complete")


def build_rocketchat_message(ctx, stack, sleep_time_sec, template_path=None):
    message_template_path = template_path or os.path.dirname(__file__) + \
            '/templates/rocketchat-sleep-before-teardown.jinja2'

    with open(message_template_path) as f:
        template_text = f.read()

    template = jinja2.Template(template_text)
    archive_path = ctx.config.get('archive_path')
    job_id = ctx.config.get('job_id')
    status = get_status(ctx.summary)
    stack_path = ' -> '.join(task for task, _ in stack)
    suite_name=ctx.config.get('suite')
    sleep_date=time.time()
    sleep_date_str=time.strftime('%Y-%m-%d %H:%M:%S',
                                 time.gmtime(sleep_date))

    message = template.render(
        sleep_time=format_timespan(sleep_time_sec),
        sleep_time_sec=sleep_time_sec,
        sleep_date=sleep_date_str,
        owner=ctx.owner,
        run_name=ctx.name,
        job_id=ctx.config.get('job_id'),
        job_desc=ctx.config.get('description'),
        job_info=get_results_url(ctx.name, job_id),

# Path: teuthology/config.py
# def init_logging():
#     def __init__(self, yaml_path=None):
#     def load(self, conf=None):
#     def update(self, in_dict):
#     def from_dict(cls, in_dict):
#     def to_dict(self):
#     def from_str(cls, in_str):
#     def to_str(self):
#     def get(self, key, default=None):
#     def __str__(self):
#     def __repr__(self):
#     def __getitem__(self, name):
#     def __getattr__(self, name):
#     def __contains__(self, name):
#     def __setattr__(self, name, value):
#     def __delattr__(self, name):
#     def __len__(self):
#     def __iter__(self):
#     def __setitem__(self, name, value):
#     def __delitem__(self, name):
#     def __init__(self, yaml_path=None):
#     def get_ceph_cm_ansible_git_url(self):
#     def get_ceph_qa_suite_git_url(self):
#     def get_ceph_git_url(self):
#     def __init__(self, config_dict=None):
#     def _clean_config(self, config_dict):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def __repr__(self):
#     def __str__(self):
# def set_config_attr(obj):
# def _get_config_path():
# class YamlConfig(collections.MutableMapping):
# class TeuthologyConfig(YamlConfig):
# class JobConfig(YamlConfig):
# class FakeNamespace(YamlConfig):
# 
# Path: teuthology/misc.py
# def get_http_log_path(archive_dir, job_id=None):
#     """
#     :param archive_dir: directory to be searched
#     :param job_id: id of job that terminates the name of the log path
#     :returns: http log path
#     """
#     http_base = config.archive_server
#     if not http_base:
#         return None
# 
#     sep = os.path.sep
#     archive_dir = archive_dir.rstrip(sep)
#     archive_subdir = archive_dir.split(sep)[-1]
#     if archive_subdir.endswith(str(job_id)):
#         archive_subdir = archive_dir.split(sep)[-2]
# 
#     if job_id is None:
#         return os.path.join(http_base, archive_subdir, '')
#     return os.path.join(http_base, archive_subdir, str(job_id), '')
# 
# def get_results_url(run_name, job_id=None):
#     """
#     :param run_name: The name of the test run
#     :param job_id: The job_id of the job. Optional.
#     :returns: URL to the run (or job, if job_id is passed) in the results web
#               UI. For example, Inktank uses Pulpito.
#     """
#     if not config.results_ui_server:
#         return None
#     base_url = config.results_ui_server
# 
#     if job_id is None:
#         return os.path.join(base_url, run_name, '')
#     return os.path.join(base_url, run_name, str(job_id), '')


# Path: teuthology/run_tasks.py
import jinja2
import logging
import os
import sys
import time
import types
import yaml
import sentry_sdk
    import smtplib
from copy import deepcopy
from humanfriendly import format_timespan
from teuthology.config import config as teuth_config
from teuthology.exceptions import ConnectionLostError
from teuthology.job_status import set_status, get_status
from teuthology.misc import get_http_log_path, get_results_url
from teuthology.timer import Timer
            from teuthology.task import interactive
                        from teuthology.task import interactive
        from rocketchat.api import RocketChatAPI
    from email.mime.text import MIMEText

            del exc_info
        timer.mark("tasks complete")


def build_rocketchat_message(ctx, stack, sleep_time_sec, template_path=None):
    message_template_path = template_path or os.path.dirname(__file__) + \
            '/templates/rocketchat-sleep-before-teardown.jinja2'

    with open(message_template_path) as f:
        template_text = f.read()

    template = jinja2.Template(template_text)
    archive_path = ctx.config.get('archive_path')
    job_id = ctx.config.get('job_id')
    status = get_status(ctx.summary)
    stack_path = ' -> '.join(task for task, _ in stack)
    suite_name=ctx.config.get('suite')
    sleep_date=time.time()
    sleep_date_str=time.strftime('%Y-%m-%d %H:%M:%S',
                                 time.gmtime(sleep_date))

    message = template.render(
        sleep_time=format_timespan(sleep_time_sec),
        sleep_time_sec=sleep_time_sec,
        sleep_date=sleep_date_str,
        owner=ctx.owner,
        run_name=ctx.name,
        job_id=ctx.config.get('job_id'),
        job_desc=ctx.config.get('description'),
        job_info=get_results_url(ctx.name, job_id),

        job_logs=get_http_log_path(archive_path, job_id),