def validate():
    """
    Performs a validation of the settings.
    Returns True if the settings are valid, otherwise False is returned.
    """
    conf = Settings()
    logger, raven_client = saxslog.setup(__name__,
                                        conf['logging']['debug'],
                                        conf['logging']['sentry'])

    # check if the watchfolder exists
    if not os.path.isdir(conf['source']['watch']):
        logger.error("The watch folder '%s' doesn't exist!"%conf['source']['watch'])
        return False
    logger.info("Watchfolder exists and is valid")

    # check if all keys in the target folder string have been declared in the
    # source folder string
    try:
        check_dict = {}
        for token in conf['source']['folder_list']:
            if token.startswith('${') and token.endswith('}'):
                check_dict[token[2:len(token)-1]] = ""
        Template(conf['target']['folder']).substitute(check_dict)
        logger.info("Source and target folder keys match")
    except KeyError, e:
        if raven_client != None:
            raven_client.captureException()
        else:
            logger.error("Key %s doesn't exist in the source folder settings!"%e)
        return False
 def __init__(self):
     """
     The constructor of the event handler.
     """
     conf = Settings()
     self._logger, self._raven_client = saxslog.setup(__name__,
                                                      conf['logging']['debug'],
                                                      conf['logging']['sentry'])
     self._stats_file = None
     self._stats_file_datetime = datetime.now()
     self._flush_counter = 0
 def __init__(self, folder_create=False, folder_folders={},
                    rsync_enabled=False, rsync_checksum=True,
                    rsync_compress=True, rsync_exclude=[],
                    post_checksum=True, post_delete=False):
     """
     Constructor of the changeover thread class
     """
     super(ChangeoverThread, self).__init__()
     conf = Settings()
     self._logger, self._raven_client = saxslog.setup(__name__,
                                                      conf['logging']['debug'],
                                                      conf['logging']['sentry'])
     self._stop = threading.Event()
import argparse
from flask import Flask
from common import saxslog
from changeover.common import settings

# parse the command line arguments
parser = argparse.ArgumentParser(prog='changeover-server',
                                 description='server to manage the changeover')
parser.add_argument('<config_file>', action='store',
                    help='Path to configuration file')
args = vars(parser.parse_args())

# read the configuration file
settings.read(args['<config_file>'])

# setup the global logging
logger, raven_client = saxslog.setup("changeover-server",
                                     settings.Settings()['logging']['debug'],
                                     settings.Settings()['logging']['sentry'])
if raven_client != None:
    saxslog.setup_logging(saxslog.SentryHandler(raven_client))
    logger.info("Raven is available. Logging will be sent to Sentry")

app = Flask(__name__)

from changeover.server import views