# Path: canaryd/log.py
# STDOUT_LOG_LEVELS = (logging.DEBUG, logging.INFO)
# STDERR_LOG_LEVELS = (logging.WARNING, logging.ERROR, logging.CRITICAL)
# class LogFilter(logging.Filter):
# class LogFormatter(logging.Formatter):
#     def __init__(self, *levels):
#     def filter(self, record):
#     def format(self, record):
# def setup_logging(verbose, debug, default_level=logging.CRITICAL):
# def setup_logging_from_settings(settings):
# def print_exception(debug_only=False):
# 
# Path: canaryd/settings.py
# def get_settings(config_file=None):
#     '''
#     Cached/public version of _get_settings.
#     '''
# 
#     global SETTINGS
# 
#     if SETTINGS is None:
#         SETTINGS = _get_settings(config_file=config_file)
# 
#     return SETTINGS
# 
# VALID_STATUSES = ('DIFF', 'SYNC', 'ERROR', 'EVENTS')
# 
# Path: canaryd/version.py



import socket
from json import dumps as json_dumps, JSONEncoder
from time import sleep
from canaryd_packages import requests, six
from canaryd.log import logger
from canaryd.settings import get_settings, VALID_STATUSES
from canaryd.version import __version__

        if hasattr(obj, 'serialise'):
            return obj.serialise()

        if hasattr(obj, 'isoformat'):
            return obj.isoformat()

        if isinstance(obj, six.binary_type):
            return obj.decode()

        return JSONEncoder.default(self, obj)


def backoff(function, *args, **kwargs):
    data = None
    interval = 0

    error_message = kwargs.pop('error_message', 'API error')
    max_wait = kwargs.pop('max_wait', 300)

    while data is None:
        try:
            return function(*args, **kwargs)

        except ApiError as e:
            if interval + 10 <= max_wait:
                interval += 10

            e.log()


# Path: canaryd/log.py
# STDOUT_LOG_LEVELS = (logging.DEBUG, logging.INFO)
# STDERR_LOG_LEVELS = (logging.WARNING, logging.ERROR, logging.CRITICAL)
# class LogFilter(logging.Filter):
# class LogFormatter(logging.Formatter):
#     def __init__(self, *levels):
#     def filter(self, record):
#     def format(self, record):
# def setup_logging(verbose, debug, default_level=logging.CRITICAL):
# def setup_logging_from_settings(settings):
# def print_exception(debug_only=False):
# 
# Path: canaryd/settings.py
# def get_settings(config_file=None):
#     '''
#     Cached/public version of _get_settings.
#     '''
# 
#     global SETTINGS
# 
#     if SETTINGS is None:
#         SETTINGS = _get_settings(config_file=config_file)
# 
#     return SETTINGS
# 
# VALID_STATUSES = ('DIFF', 'SYNC', 'ERROR', 'EVENTS')
# 
# Path: canaryd/version.py



# Path: canaryd/remote.py
import socket
from json import dumps as json_dumps, JSONEncoder
from time import sleep
from canaryd_packages import requests, six
from canaryd.log import logger
from canaryd.settings import get_settings, VALID_STATUSES
from canaryd.version import __version__


        if hasattr(obj, 'serialise'):
            return obj.serialise()

        if hasattr(obj, 'isoformat'):
            return obj.isoformat()

        if isinstance(obj, six.binary_type):
            return obj.decode()

        return JSONEncoder.default(self, obj)


def backoff(function, *args, **kwargs):
    data = None
    interval = 0

    error_message = kwargs.pop('error_message', 'API error')
    max_wait = kwargs.pop('max_wait', 300)

    while data is None:
        try:
            return function(*args, **kwargs)

        except ApiError as e:
            if interval + 10 <= max_wait:
                interval += 10

            e.log()


        logger.critical('{0}, retrying in {1}s'.format(error_message, interval))