# 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_scripts_directory():
#     return path.join(get_config_directory(), 'scripts')


from distutils.spawn import find_executable
from os import access, listdir, makedirs, path, remove, symlink, X_OK
from shutil import copy
from canaryd.log import logger
from canaryd.settings import get_scripts_directory
        raise NoScriptChangesError()

    if not path.islink(link_name):
        raise ScriptNotLinkError(
            'Script {0} is not a link. You should move it to: {1}.'.format(
                link_name, source_script,
            ),
        )

    remove(link_name)


def ensure_scripts_directory():
    # Make sure the scripts directory exists
    scripts_directory = get_scripts_directory()

    if not path.exists(scripts_directory):
        logger.debug('Creating scripts directory: {0}'.format(scripts_directory))

        # Make the scripts, scripts/enabled & scripts/available directories
        makedirs(path.join(scripts_directory, 'enabled'))
        makedirs(path.join(scripts_directory, 'available'))

        copy_builtin_scripts()


def copy_builtin_scripts(enable_where_possible=True):
    # Copy built in scripts to the scripts/available directory
    available_scripts_directory = path.join(get_scripts_directory(), 'available')


# 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_scripts_directory():
#     return path.join(get_config_directory(), 'scripts')


# Path: canaryd/script.py
from distutils.spawn import find_executable
from os import access, listdir, makedirs, path, remove, symlink, X_OK
from shutil import copy
from canaryd.log import logger
from canaryd.settings import get_scripts_directory

        raise NoScriptChangesError()

    if not path.islink(link_name):
        raise ScriptNotLinkError(
            'Script {0} is not a link. You should move it to: {1}.'.format(
                link_name, source_script,
            ),
        )

    remove(link_name)


def ensure_scripts_directory():
    # Make sure the scripts directory exists
    scripts_directory = get_scripts_directory()

    if not path.exists(scripts_directory):
        logger.debug('Creating scripts directory: {0}'.format(scripts_directory))

        # Make the scripts, scripts/enabled & scripts/available directories
        makedirs(path.join(scripts_directory, 'enabled'))
        makedirs(path.join(scripts_directory, 'available'))

        copy_builtin_scripts()


def copy_builtin_scripts(enable_where_possible=True):
    # Copy built in scripts to the scripts/available directory
    available_scripts_directory = path.join(get_scripts_directory(), 'available')


    logger.debug(