from flask import Flask

app = Flask(__name__)
app.config.from_object('saltobserver.config')
app.config.from_envvar('SALTOBSERVER_SETTINGS')

import logging
from logging import Formatter
from logging.handlers import RotatingFileHandler

file_handler = RotatingFileHandler(app.config['LOG_FILE'])
file_handler.setFormatter(Formatter(
    '%(asctime)s %(levelname)s: %(message)s '
    '[in %(pathname)s:%(lineno)d]'
    ))
app.logger.addHandler(file_handler)
app.logger.setLevel(logging.DEBUG)

if app.config['USE_LIVEUPDATES']:
    from saltobserver.redis_stream import RedisStream
    try:
        stream = RedisStream()
        stream.start()
    except NotImplementedError:
        app.config['USE_LIVEUPDATES'] = False # override configuration
        app.logger.error("Live updates not available, Redis version not sufficient (minimum is v2.8).")

import saltobserver.filters
import saltobserver.views
if app.config['USE_LIVEUPDATES']:
    import saltobserver.websockets

@@ -86,16 +86,25 @@
 onfig')%0A
+try:%0A    
 app.conf
@@ -142,16 +142,296 @@
 TTINGS')
+%0Aexcept RuntimeError:%0A    print %22No custom settings found! Point $SALTOBSERVER_SETTINGS to your configuration file.%22%0A    print %22You might want to base them on the defaults:%22%0A    print %22  wget https://raw.githubusercontent.com/analogbyte/saltobserver/master/saltobserver/config.py%22
 %0A%0Aimport

make custom settings not mandatory