Beispiel #1
0
    def __init__(self):
        self.__logger = logging.getLogger('MODEL.MAPPING')
        self.__logger.setLevel(Options().default_logging_level)

        self.__data()
Beispiel #2
0
    def __engine_settings(settings_yaml):
        # defaults
        try:
            socket_host = settings_yaml['server']['socket_host']
        except KeyError:
            socket_host = '127.0.0.1'

        try:
            socket_port = settings_yaml['server']['socket_port']
        except KeyError:
            socket_port = 8080

        try:
            thread_pool = settings_yaml['server']['thread_pool']
        except KeyError:
            thread_pool = 8

        try:
            autoreload = settings_yaml['engine']['autoreload']
        except KeyError:
            autoreload = True

        global_settings = {
            'server.socket_host': socket_host,
            'server.socket_port': socket_port,
            'server.thread_pool': thread_pool,
            'engine.autoreload.on': autoreload,
        }

        settings = {'global': global_settings}

        try:
            for staticdir in settings_yaml['tools']['staticdirs']:
                url = staticdir['url']
                absolute = staticdir['absolute']
                path = staticdir['path']

                if not absolute:
                    path = os.path.abspath(os.path.join(os.getcwd(), path))

                settings[url] = {
                    'tools.staticdir.on': True,
                    'tools.staticdir.dir': path
                }
        except KeyError:
            pass

        try:
            for staticfile in settings_yaml['tools']['staticfiles']:
                url = staticfile['url']
                absolute = staticfile['absolute']
                path = staticfile['path']

                if not absolute:
                    path = os.path.abspath(os.path.join(os.getcwd(), path))

                settings[url] = {
                    'tools.staticfile.on': True,
                    'tools.staticfile.filename': path
                }
        except KeyError:
            pass

        try:
            settings['/favicon.ico'] = {
                'tools.staticfile.on':
                True,
                'tools.staticfile.filename':
                os.path.abspath(
                    os.path.join(Options().data_dir, 'images', 'favicon.ico'))
            }
        except FileNotFoundError:
            pass

        return settings
Beispiel #3
0
    def __option_settings(settings_yaml):
        # The individual properties are logged in main
        # No need to log them here

        try:
            Options().theme_dir = settings_yaml['directories']['theme']['path']
        except KeyError:
            Options().theme_dir = os.path.join(
                os.getcwd(), settings_yaml['directories']['theme']['path'])

        try:
            Options().log_dir = settings_yaml['directories']['log']['path']
        except KeyError:
            Options().log_dir = os.path.join(
                os.getcwd(), settings_yaml['directories']['log']['path'])

        try:
            Options().run_dir = settings_yaml['directories']['run']['path']
        except KeyError:
            Options().run_dir = os.path.join(
                os.getcwd(), settings_yaml['directories']['run']['path'])

        try:
            Options().meta_content_separator = settings_yaml['content'][
                'meta_content_separator']
        except KeyError:
            Options().meta_content_separator = '__________'

        try:
            Options(
            ).include_drafts = settings_yaml['content']['include_drafts']
        except KeyError:
            Options().include_drafts = False

        try:
            Options().daemon = settings_yaml['engine']['daemon']
        except KeyError:
            Options().daemon = False

        try:
            Options().privileges = settings_yaml['user']['privileges']
        except KeyError:
            Options().privileges = False

        try:
            Options().uid = settings_yaml['user']['uid']
        except KeyError:
            Options().uid = 0

        try:
            Options().gid = settings_yaml['user']['gid']
        except KeyError:
            Options().gid = 0

        try:
            use_ssl = False

            Options().ssl_certificate = settings_yaml['ssl']['ssl_certificate']
            Options().ssl_private_key = settings_yaml['ssl']['ssl_private_key']
            Options().ssl_certificate_chain = settings_yaml['ssl'][
                'ssl_certificate_chain']

            if Options().ssl_certificate != '':
                use_ssl = True

            if Options().ssl_private_key != '':
                use_ssl = True

            if Options().ssl_certificate_chain != '':
                use_ssl = True

        except KeyError:
            use_ssl = False

        Options().use_ssl = use_ssl

        try:
            Options().caching = settings_yaml['caching']['use']
        except KeyError:
            Options().caching = False
Beispiel #4
0
 def __init__(self):
     self.__logger = logging.getLogger('MODEL.INDEX')
     self.__logger.setLevel(Options().default_logging_level)
Beispiel #5
0
 def __init__(self):
     self.__logger = logging.getLogger('DATA_CACHER')
     self.__logger.setLevel(Options().default_logging_level)
Beispiel #6
0
import logging
import os

from pathlib import Path

from common.options import Options
from common.content import Content
from controller.data_loader import DataLoader
from controller.logging_loader import LoggingLoader
from controller.remapper import Remapper
from controller.settings_loader import SettingsLoader

environment = 'localhost'
data_dir = os.path.join(os.getcwd(), 'src', 'data')

Options().environment = environment
Options().data_dir = data_dir

settings = SettingsLoader(environment).parse()

LoggingLoader().configure()

logger = logging.getLogger('SITEMAP')

logger.debug('data_dir: {0}'.format(data_dir))

Remapper().outgoing_content = DataLoader().mapping_outgoing()
Remapper().incoming_content = DataLoader().mapping_incoming()

# Override the drafts because Google will never find them in production most likely
Options().include_drafts = False