# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
#     return _t.ugettext(msg)
# 
# Path: tuskar/openstack/common/log.py
# _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
# CONF = cfg.CONF
#     LEVEL_COLORS = {
#         logging.DEBUG: '\033[00;32m',  # GREEN
#         logging.INFO: '\033[00;36m',  # CYAN
#         logging.AUDIT: '\033[01;36m',  # BOLD CYAN
#         logging.WARN: '\033[01;33m',  # BOLD YELLOW
#         logging.ERROR: '\033[01;31m',  # BOLD RED
#         logging.CRITICAL: '\033[01;31m',  # BOLD RED
#     }
#     class NullHandler(logging.Handler):
# class BaseLoggerAdapter(logging.LoggerAdapter):
# class LazyAdapter(BaseLoggerAdapter):
# class ContextAdapter(BaseLoggerAdapter):
# class JSONFormatter(logging.Formatter):
# class LogConfigError(Exception):
# class WritableLogger(object):
# class ContextFormatter(logging.Formatter):
# class ColorHandler(logging.StreamHandler):
# class DeprecatedConfig(Exception):
#         def handle(self, record):
#         def emit(self, record):
#         def createLock(self):
# def _dictify_context(context):
# def _get_binary_name():
# def _get_log_file_path(binary=None):
#     def audit(self, msg, *args, **kwargs):
#     def __init__(self, name='unknown', version='unknown'):
#     def logger(self):
#     def __init__(self, logger, project_name, version_string):
#     def handlers(self):
#     def deprecated(self, msg, *args, **kwargs):
#     def process(self, msg, kwargs):
#     def __init__(self, fmt=None, datefmt=None):
#     def formatException(self, ei, strip_newlines=True):
#     def format(self, record):
# def _create_logging_excepthook(product_name):
#     def logging_excepthook(type, value, tb):
#     def __init__(self, log_config, err_msg):
#     def __str__(self):
# def _load_log_config(log_config):
# def setup(product_name):
# def set_defaults(logging_context_format_string):
# def _find_facility_from_conf():
# def _setup_logging_from_conf():
# def getLogger(name='unknown', version='unknown'):
# def getLazyLogger(name='unknown', version='unknown'):
#     def __init__(self, logger, level=logging.INFO):
#     def write(self, msg):
#     def format(self, record):
#     def formatException(self, exc_info, record=None):
#     def format(self, record):
#     def __init__(self, msg):
# 
# Path: tuskar/openstack/common/timeutils.py
# _ISO8601_TIME_FORMAT_SUBSECOND = '%Y-%m-%dT%H:%M:%S.%f'
# _ISO8601_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
# PERFECT_TIME_FORMAT = _ISO8601_TIME_FORMAT_SUBSECOND
# def isotime(at=None, subsecond=False):
# def parse_isotime(timestr):
# def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
# def parse_strtime(timestr, fmt=PERFECT_TIME_FORMAT):
# def normalize_time(timestamp):
# def is_older_than(before, seconds):
# def is_newer_than(after, seconds):
# def utcnow_ts():
# def utcnow():
# def iso8601_from_timestamp(timestamp):
# def set_time_override(override_time=datetime.datetime.utcnow()):
# def advance_time_delta(timedelta):
# def advance_time_seconds(seconds):
# def clear_time_override():
# def marshall_now(now=None):
# def unmarshall_time(tyme):
# def delta_seconds(before, after):
# def is_soon(dt, window):


import sys
from eventlet import event
from eventlet import greenthread
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import log as logging
from tuskar.openstack.common import timeutils


class LoopingCallBase(object):
    def __init__(self, f=None, *args, **kw):
        self.args = args
        self.kw = kw
        self.f = f
        self._running = False
        self.done = None

    def stop(self):
        self._running = False

    def wait(self):
        return self.done.wait()


class FixedIntervalLoopingCall(LoopingCallBase):
    """A fixed interval looping call."""

    def start(self, interval, initial_delay=None):
        self._running = True
        done = event.Event()

        def _inner():
            if initial_delay:
                greenthread.sleep(initial_delay)

            try:
                while self._running:

# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
#     return _t.ugettext(msg)
# 
# Path: tuskar/openstack/common/log.py
# _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
# CONF = cfg.CONF
#     LEVEL_COLORS = {
#         logging.DEBUG: '\033[00;32m',  # GREEN
#         logging.INFO: '\033[00;36m',  # CYAN
#         logging.AUDIT: '\033[01;36m',  # BOLD CYAN
#         logging.WARN: '\033[01;33m',  # BOLD YELLOW
#         logging.ERROR: '\033[01;31m',  # BOLD RED
#         logging.CRITICAL: '\033[01;31m',  # BOLD RED
#     }
#     class NullHandler(logging.Handler):
# class BaseLoggerAdapter(logging.LoggerAdapter):
# class LazyAdapter(BaseLoggerAdapter):
# class ContextAdapter(BaseLoggerAdapter):
# class JSONFormatter(logging.Formatter):
# class LogConfigError(Exception):
# class WritableLogger(object):
# class ContextFormatter(logging.Formatter):
# class ColorHandler(logging.StreamHandler):
# class DeprecatedConfig(Exception):
#         def handle(self, record):
#         def emit(self, record):
#         def createLock(self):
# def _dictify_context(context):
# def _get_binary_name():
# def _get_log_file_path(binary=None):
#     def audit(self, msg, *args, **kwargs):
#     def __init__(self, name='unknown', version='unknown'):
#     def logger(self):
#     def __init__(self, logger, project_name, version_string):
#     def handlers(self):
#     def deprecated(self, msg, *args, **kwargs):
#     def process(self, msg, kwargs):
#     def __init__(self, fmt=None, datefmt=None):
#     def formatException(self, ei, strip_newlines=True):
#     def format(self, record):
# def _create_logging_excepthook(product_name):
#     def logging_excepthook(type, value, tb):
#     def __init__(self, log_config, err_msg):
#     def __str__(self):
# def _load_log_config(log_config):
# def setup(product_name):
# def set_defaults(logging_context_format_string):
# def _find_facility_from_conf():
# def _setup_logging_from_conf():
# def getLogger(name='unknown', version='unknown'):
# def getLazyLogger(name='unknown', version='unknown'):
#     def __init__(self, logger, level=logging.INFO):
#     def write(self, msg):
#     def format(self, record):
#     def formatException(self, exc_info, record=None):
#     def format(self, record):
#     def __init__(self, msg):
# 
# Path: tuskar/openstack/common/timeutils.py
# _ISO8601_TIME_FORMAT_SUBSECOND = '%Y-%m-%dT%H:%M:%S.%f'
# _ISO8601_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
# PERFECT_TIME_FORMAT = _ISO8601_TIME_FORMAT_SUBSECOND
# def isotime(at=None, subsecond=False):
# def parse_isotime(timestr):
# def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
# def parse_strtime(timestr, fmt=PERFECT_TIME_FORMAT):
# def normalize_time(timestamp):
# def is_older_than(before, seconds):
# def is_newer_than(after, seconds):
# def utcnow_ts():
# def utcnow():
# def iso8601_from_timestamp(timestamp):
# def set_time_override(override_time=datetime.datetime.utcnow()):
# def advance_time_delta(timedelta):
# def advance_time_seconds(seconds):
# def clear_time_override():
# def marshall_now(now=None):
# def unmarshall_time(tyme):
# def delta_seconds(before, after):
# def is_soon(dt, window):


# Path: tuskar/openstack/common/loopingcall.py
import sys
from eventlet import event
from eventlet import greenthread
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import log as logging
from tuskar.openstack.common import timeutils



class LoopingCallBase(object):
    def __init__(self, f=None, *args, **kw):
        self.args = args
        self.kw = kw
        self.f = f
        self._running = False
        self.done = None

    def stop(self):
        self._running = False

    def wait(self):
        return self.done.wait()


class FixedIntervalLoopingCall(LoopingCallBase):
    """A fixed interval looping call."""

    def start(self, interval, initial_delay=None):
        self._running = True
        done = event.Event()

        def _inner():
            if initial_delay:
                greenthread.sleep(initial_delay)

            try:
                while self._running:

                    start = timeutils.utcnow()