Ejemplo n.º 1
0
def api_settings(db):
    '''
    WebUI Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_webui.html').render(
        auth=auth(request),
        web_theme=setting('web_theme').value,
        web_header=setting('web_header').value,
        web_images=setting('web_images').boolvalue,
        web_accounts=setting('web_accounts').boolvalue,
        web_stats=setting('web_stats').intvalue,
        web_pvs=setting('web_pvs_enabled').boolvalue,
        web_image_delay=setting('web_image_delay').value,
        web_account_delay=setting('web_account_delay').value,
        web_stat_delay=setting('web_stat_delay').value,
        web_pvs_delay=setting('web_pvs_delay').value,
        web_stat_max=setting('web_stat_max').intvalue,
        web_image_max=setting('web_image_max').intvalue,
        web_account_max=setting('web_account_max').intvalue,
        web_pvs_max=setting('web_pvs_max').intvalue,
        pvs_host=setting('pvs_host').value,
        pvs_user=setting('pvs_user').value,
        pvs_password=setting('pvs_password').value,
        web_display_settings=setting('web_display_settings').boolvalue
    )
Ejemplo n.º 2
0
def user_settings(db):
    '''
    User Management Page
    '''
    s = SettingSession()
    if auth(request) and request.method == 'POST':
        username = request.forms.get('username')
        password = request.forms.get('password')
        action = request.forms.get('action')
        if action == 'Create':
            s.add(User(username, password))
        if action == 'Update':
            user = s.query(User).filter_by(name=username).one()
            user.update(password)
            s.merge(user)
        if action == 'Remove' and username != 'admin':
            user = s.query(User).filter_by(name=username).one()
            s.delete(user)
        s.commit()
    users = s.query(User).all()
    s.close()
    return env.get_template('settings_users.html').render(
        auth=auth(request),
        users=users
    )
Ejemplo n.º 3
0
def api_settings(db):
    '''
    WebUI Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_webui.html').render(
        auth=auth(request),
        web_theme=setting('web_theme').value,
        web_header=setting('web_header').value,
        web_images=setting('web_images').boolvalue,
        web_accounts=setting('web_accounts').boolvalue,
        web_stats=setting('web_stats').intvalue,
        web_pvs=setting('web_pvs_enabled').boolvalue,
        web_image_delay=setting('web_image_delay').value,
        web_account_delay=setting('web_account_delay').value,
        web_stat_delay=setting('web_stat_delay').value,
        web_pvs_delay=setting('web_pvs_delay').value,
        web_stat_max=setting('web_stat_max').intvalue,
        web_image_max=setting('web_image_max').intvalue,
        web_account_max=setting('web_account_max').intvalue,
        web_pvs_max=setting('web_pvs_max').intvalue,
        pvs_host=setting('pvs_host').value,
        pvs_user=setting('pvs_user').value,
        pvs_password=setting('pvs_password').value,
        web_display_settings=setting('web_display_settings').boolvalue)
Ejemplo n.º 4
0
def services_settings(db):
    '''
    Services Status Page 
    '''
    if auth(request) and request.method == 'POST':
        parser = request.forms.get('parser')
        action = request.forms.get('action')
        if action == 'Stop':
            monitor.stop(parser)
        if action == 'Start':
            monitor.start(parser)
        if action == 'Restart':
            monitor.stop(parser)
            monitor.start(parser)
    return env.get_template('settings_services.html').render(
        auth=auth(request), parsers=monitor.parser_status())
Ejemplo n.º 5
0
def api_settings(db):
    '''
    Logging Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_logging.html').render(
        auth=auth(request),
        log_console=setting('log_console').intvalue,
        log_console_level=setting('log_console_level').value,
        log_file=setting('log_file').intvalue,
        log_file_level=setting('log_file_level').value,
        log_file_path=setting('log_file_path').value)
Ejemplo n.º 6
0
def api_settings(db):
    '''
    Server Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_server.html').render(
        auth=auth(request),
        server_host=setting('server_host').value,
        server_port=setting('server_port').value,
        server_ssl=setting('server_ssl').intvalue,
        server_anonymize=setting('server_anonymize').intvalue,
        server_username=setting('server_username').value)
Ejemplo n.º 7
0
def login_page(db):
    '''
    Authentication Screen
    '''
    return env.get_template('login.html').render(
        auth=auth(request), 
        status=monitor.status()
    )
Ejemplo n.º 8
0
def api_settings(db):
    '''
    Logging Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_logging.html').render(
        auth=auth(request),
        log_console=setting('log_console').intvalue,
        log_console_level=setting('log_console_level').value,
        log_file=setting('log_file').intvalue,
        log_file_level=setting('log_file_level').value,
        log_file_path=setting('log_file_path').value
    )
Ejemplo n.º 9
0
def api_settings(db):
    '''
    API Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_api.html').render(
        auth=auth(request),
        api_debug=setting('api_debug').intvalue,
        api_port=setting('api_port').value,
        api_host=setting('api_host').value,
        api_app_server=setting('api_app_server').value,
        cookie_key=setting('cookie_key').value,
        database=config.config.get('Database', 'db'))
Ejemplo n.º 10
0
def new_user_page(db):
    '''
    New User Page. 
    '''
    return env.get_template('newuser.html').render(
        auth=auth(request), 
        status=monitor.status()
    )
Ejemplo n.º 11
0
def settings_page(db):
    '''
    Settings Page
    '''
    return env.get_template('settings_base.html').render(
        auth=auth(request),
        vinfo=get_version_info()
    )
Ejemplo n.º 12
0
def api_settings(db):
    '''
    Server Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_server.html').render(
        auth=auth(request),
        server_host=setting('server_host').value,
        server_port=setting('server_port').value,
        server_ssl=setting('server_ssl').intvalue,
        server_anonymize=setting('server_anonymize').intvalue,
        server_username=setting('server_username').value
    )
Ejemplo n.º 13
0
def start_parser(parser, db):
    '''
    Starts the parser specified. 
    '''
    if auth(request):
        monitor.start(parser)
        return env.get_template('parsers.html').render(
            parsers=monitor.parser_status(),
            auth=auth(request), 
            status=monitor.status()
        )
    else:
        return env.get_template('parsers.html').render(
            error='Must be Authenticated to Start Parsers',
            parsers=monitor.parser_status(),
            auth=auth(request), 
            status=monitor.status()
        )
Ejemplo n.º 14
0
def status_page(db):
    '''
    Parser Status Page. 
    '''
    return env.get_template('parsers.html').render(
        parsers=monitor.parser_status(),
        auth=auth(request), 
        status=monitor.status()
    )
Ejemplo n.º 15
0
Archivo: post.py Proyecto: xme/DoFler
def upload_stat(db):
    '''Uploads new statistics to the database.'''
    if auth(request):
        username = request.forms.get('username')
        proto = request.forms.get('proto')
        count = int(request.forms.get('count'))
        if isinstance(username, tuple): sensor = sensor[0]
        if isinstance(proto, tuple): proto = proto[0]
        db.add(Stat(proto, username, count))
Ejemplo n.º 16
0
def api_settings(db):
    '''
    API Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_api.html').render(
        auth=auth(request),
        api_debug=setting('api_debug').intvalue,
        api_port=setting('api_port').value,
        api_host=setting('api_host').value,
        api_app_server=setting('api_app_server').value,
        cookie_key=setting('cookie_key').value,
        database=config.config.get('Database', 'db')
    )
Ejemplo n.º 17
0
def upload_stat(db):
    '''Uploads new statistics to the database.'''
    if auth(request):
        username = request.forms.get('username')
        proto = request.forms.get('proto')
        count = int(request.forms.get('count'))
        if isinstance(username, tuple): sensor = sensor[0]
        if isinstance(proto, tuple): proto = proto[0]
        db.add(Stat(proto, username, count))
Ejemplo n.º 18
0
def services_settings(db):
    '''
    Services Status Page 
    '''
    if auth(request) and request.method == 'POST':
        parser = request.forms.get('parser')
        action = request.forms.get('action')
        if action == 'Stop':
            monitor.stop(parser)
        if action == 'Start':
            monitor.start(parser)
        if action == 'Restart':
            monitor.stop(parser)
            monitor.start(parser)
    return env.get_template('settings_services.html').render(
        auth=auth(request),
        parsers=monitor.parser_status()
    )
Ejemplo n.º 19
0
def parsers_settings(db):
    '''
    Parser Configuration Settings Page
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    parsers = {}
    for item in monitor.parser_status():
        parsers[item] = {
            'enabled': setting('%s_enabled' % item).boolvalue,
            'command': setting('%s_command' % item).value,
        }
    return env.get_template('settings_parsers.html').render(
        auth=auth(request),
        parsers=parsers,
        autostart=setting('autostart').boolvalue,
        listen_interface=setting('listen_interface').value)
Ejemplo n.º 20
0
def new_user_post(db):
    '''
    New User Handler. 
    '''
    if auth(request):
        db.add(User(
            request.forms.get('username'),
            request.forms.get('password')
        ))
        return eng.get_template('newuser.html').render(
            note='Account Created',
            auth=auth(request), 
            status=monitor.status()
        )
    else:
        return eng.get_template('newuser.html').render(
            error='Must be Logged in to create accounts.',
            auth=auth(request), 
            status=monitor.status()
        )
Ejemplo n.º 21
0
def parsers_settings(db):
    '''
    Parser Configuration Settings Page
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    parsers = {}
    for item in monitor.parser_status():
        parsers[item] = {
            'enabled': setting('%s_enabled' % item).boolvalue,
            'command': setting('%s_command' % item).value,
        }
    return env.get_template('settings_parsers.html').render(
        auth=auth(request),
        parsers=parsers,
        autostart=setting('autostart').boolvalue,
        listen_interface=setting('listen_interface').value
    )
Ejemplo n.º 22
0
Archivo: ui.py Proyecto: blha303/DoFler
def api_settings(db):
    '''
    WebUI Settings Page 
    '''
    if auth(request) and request.method == 'POST':
        settings = {}
        for item in request.forms:
            settings[item] = request.forms[item]
        update_settings(settings)
    return env.get_template('settings_webui.html').render(
        auth=auth(request),
        web_images=setting('web_images').boolvalue,
        web_accounts=setting('web_accounts').boolvalue,
        web_stats=setting('web_stats').intvalue,
        web_image_delay=setting('web_image_delay').value,
        web_account_delay=setting('web_account_delay').value,
        web_stat_delay=setting('web_stat_delay').value,
        web_stat_max=setting('web_stat_max').intvalue,
        web_image_max=setting('web_image_max').intvalue,
        web_account_max=setting('web_account_max').intvalue,
        web_display_settings=setting('web_display_settings').boolvalue
    )
Ejemplo n.º 23
0
def settings_post(db):
    '''
    Settings Update Handler. 
    '''
    s = SettingSession()
    if auth(request):
        for item in request.forms:
            settingobj = setting(item)
            if item == 'server_password':
                if request.forms['server_password'] != '1234567890':
                    settingobj.value = request.forms[item]
            else:
                settingobj.value = request.forms[item]
            s.merge(settingobj)
        s.commit()
        s.close()
        common.log_to_console()
        common.log_to_file()
        monitor.autostart()
        return get_settings_page(auth(request), note='Settings Updated')
    else:
        return get_settings_page(auth(request),
            error='Must be Authenticated to Change Settings')
Ejemplo n.º 24
0
def user_settings(db):
    '''
    User Management Page
    '''
    s = SettingSession()
    if auth(request) and request.method == 'POST':
        username = request.forms.get('username')
        password = request.forms.get('password')
        action = request.forms.get('action')
        if action == 'Create':
            s.add(User(username, password))
        if action == 'Update':
            user = s.query(User).filter_by(name=username).one()
            user.update(password)
            s.merge(user)
        if action == 'Remove' and username != 'admin':
            user = s.query(User).filter_by(name=username).one()
            s.delete(user)
        s.commit()
    users = s.query(User).all()
    s.close()
    return env.get_template('settings_users.html').render(auth=auth(request),
                                                          users=users)
Ejemplo n.º 25
0
def upload_image(db):
    '''Updates and/or creates a image object into the database.'''
    if auth(request):
        filedata = request.files.file.file.read()
        md5sum = md5hash(filedata)
        try:
            image = db.query(Image).filter_by(md5sum=md5sum).one()
            image.timestamp = int(time.time())
            image.count += 1
            db.merge(image)
        except:
            image = Image(int(time.time()), request.forms.get('filetype'),
                          filedata)
            db.add(image)
Ejemplo n.º 26
0
def services(db):
    '''
    Returns the running status of the services on the dofler sensor. 
    '''
    if auth(request) and request.method == 'POST':
        parser = request.forms.get('parser') or None
        action = request.forms.get('action') or None
        if action == 'Stop':
            monitor.stop(parser)
        if action == 'Start':
            monitor.start(parser)
        if action == 'Restart':
            monitor.stop(parser)
            monitor.start(parser)
    return jsonify(monitor.parser_status())
Ejemplo n.º 27
0
Archivo: post.py Proyecto: xme/DoFler
def services(db):
    '''
    Returns the running status of the services on the dofler sensor. 
    '''
    if auth(request) and request.method == 'POST':
        parser = request.forms.get('parser') or None
        action = request.forms.get('action') or None
        if action == 'Stop':
            monitor.stop(parser)
        if action == 'Start':
            monitor.start(parser)
        if action == 'Restart':
            monitor.stop(parser)
            monitor.start(parser)
    return jsonify(monitor.parser_status())
Ejemplo n.º 28
0
Archivo: post.py Proyecto: xme/DoFler
def upload_image(db):
    '''Updates and/or creates a image object into the database.'''
    if auth(request):
        filedata = request.files.file.file.read()
        md5sum = md5hash(filedata)
        try:
            image = db.query(Image).filter_by(md5sum=md5sum).one()
            image.timestamp = int(time.time())
            image.count += 1
            db.merge(image)
        except:
            image = Image(int(time.time()), 
                          request.forms.get('filetype'),
                          filedata
            )
            db.add(image)
Ejemplo n.º 29
0
def documentation(db, path=None):
    '''
    Documentation Pages.
    '''
    data = None
    if path:
        try:
            with open('/usr/share/dofler/docs/%s.md' % path) as mdfile:
                data = markdown.markdown(mdfile.read(),
                                         extensions=[
                                             'codehilite',
                                             'extra',
                                         ])
        except:
            pass
    return env.get_template('settings_doc_page.html').render(
        auth=auth(request), doc_content=data)
Ejemplo n.º 30
0
def main_page(db):
    '''
    Main View
    '''
    return env.get_template('main.html').render(
        auth=auth(request), 
        status=monitor.status(),
        web_images=setting('web_images').boolvalue,
        web_accounts=setting('web_accounts').boolvalue,
        web_stats=setting('web_stats').boolvalue,
        web_image_delay=setting('web_image_delay').intvalue,
        web_account_delay=setting('web_account_delay').intvalue,
        web_stat_delay=setting('web_stat_delay').intvalue,
        web_image_max=setting('web_image_max').intvalue,
        web_account_max=setting('web_account_max').intvalue,
        web_stat_max=setting('web_stat_max').intvalue
    )
Ejemplo n.º 31
0
def documentation(db, path=None):
    '''
    Documentation Pages.
    '''
    data = None
    if path:
        try:
            with open('/usr/share/dofler/docs/%s.md' % path) as mdfile:
                data = markdown.markdown(mdfile.read(), extensions=[
                    'codehilite',
                    'extra',
                ])
        except:
            pass
    return env.get_template('settings_doc_page.html').render(
        auth=auth(request),
        doc_content=data
    )
Ejemplo n.º 32
0
def login(db):
    '''
    Authentication Page
    '''
    error = None
    logged_in = False
    if request.method == 'POST':
        if auth_login(request):
            response.set_cookie(
                'user',
                request.forms.get('username'),
                secret=setting('cookie_key').value,
            )
            response.add_header('Authentication', 'SUCCESS')
            logged_in = True
        else:
            error = 'Authentication Failed'
    else:
        logged_in = auth(request)
    return env.get_template('settings_login.html').render(auth=logged_in,
                                                          error=error)
Ejemplo n.º 33
0
def new_account(db):
    '''Generates a new account into the database if it doesnt already exist.'''
    if auth(request):
        username = str(request.forms.get('username')),
        password = str(request.forms.get('password')),
        info = str(request.forms.get('info')),
        proto = str(request.forms.get('proto')),
        parser = str(request.forms.get('parser')),
        if isinstance(username, tuple): username = username[0]
        if isinstance(password, tuple): password = password[0]
        if isinstance(info, tuple): info = info[0]
        if isinstance(proto, tuple): proto = proto[0]
        if isinstance(parser, tuple): parser = parser[0]
        try:
            account = db.query(Account).filter_by(username=username,
                                                 proto=proto,
                                                 password=password,
                                                 info=info).one()
        except:
            account = Account(username, password, info, proto, parser)
            db.add(account)
Ejemplo n.º 34
0
def new_account(db):
    '''Generates a new account into the database if it doesnt already exist.'''
    if auth(request):
        username = str(request.forms.get('username')),
        password = str(request.forms.get('password')),
        info = str(request.forms.get('info')),
        proto = str(request.forms.get('proto')),
        parser = str(request.forms.get('parser')),
        if isinstance(username, tuple): username = username[0]
        if isinstance(password, tuple): password = password[0]
        if isinstance(info, tuple): info = info[0]
        if isinstance(proto, tuple): proto = proto[0]
        if isinstance(parser, tuple): parser = parser[0]
        try:
            account = db.query(Account).filter_by(username=username,
                                                  proto=proto,
                                                  password=password,
                                                  info=info).one()
        except:
            account = Account(username, password, info, proto, parser)
            db.add(account)
Ejemplo n.º 35
0
def login(db):
    '''
    Authentication Page
    '''
    error=None
    logged_in=False
    if request.method == 'POST':
        if auth_login(request):
            response.set_cookie('user', 
                request.forms.get('username'), 
                secret=setting('cookie_key').value,
            )
            response.add_header('Authentication', 'SUCCESS')
            logged_in=True
        else:
            error='Authentication Failed'
    else:
        logged_in=auth(request)
    return env.get_template('settings_login.html').render(
        auth=logged_in,
        error=error
    )
Ejemplo n.º 36
0
Archivo: post.py Proyecto: xme/DoFler
def push_reset(db):
    '''
    Pushes a reset into the DB to clear out any undesirable data from the UI. 
    '''
    if auth(request):
        db.add(Reset(request.forms.get('type')))
Ejemplo n.º 37
0
def settings_page(db):
    '''
    Settings Page
    '''
    return env.get_template('settings_base.html').render(
        auth=auth(request), vinfo=get_version_info())
Ejemplo n.º 38
0
def settings_page(db):
    '''
    Settings Page
    '''
    return get_settings_page(auth(request))
Ejemplo n.º 39
0
def push_reset(db):
    '''
    Pushes a reset into the DB to clear out any undesirable data from the UI. 
    '''
    if auth(request):
        db.add(Reset(request.forms.get('type')))