<commit_before>from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash, jsonify
import lxclite as lxc
import lwp
import subprocess
import time
import re
import hashlib
import signal
import sqlite3
import os
import ConfigParser

# configuration
config = ConfigParser.SafeConfigParser()
config.readfp(open('lwp.conf'))

SECRET_KEY = <KEY>

DEBUG = config.getboolean('global', 'debug')
DATABASE = config.get('database', 'file')
ADDRESS = config.get('global', 'address')
PORT = int(config.get('global', 'port'))


# Flask app
app = Flask(__name__)
app.config['TRAP_BAD_REQUEST_ERRORS'] = True
app.config.from_object(__name__)


def connect_db():
    '''
    SQLite3 connect function
    '''
    return sqlite3.connect(app.config['DATABASE'])


@app.before_request
def before_request():
    '''
    executes functions before all requests
    '''
    check_session_limit()
    g.db = connect_db()


@app.teardown_request
def teardown_request(exception):
    '''
    executes functions after all requests
    '''
    if hasattr(g, 'db'):
        g.db.close()


@app.route('/')
@app.route('/home')
def home():
    '''
    home page function
    '''
    if 'logged_in' in session:
        
        listx = lxc.listx()
        containers_all = []

        for status in ['RUNNING', 'FROZEN', 'STOPPED']:
            containers_by_status = []
            print status
            for container in listx[status]:
                containers_by_status.append({
                    'name': container,
                    'memusg': lwp.memory_usage(container),
                    'settings': lwp.get_container_settings(container)
                })
            containers_all.append({
                        'status' : status.lower(),
                        'containers' : containers_by_status
                })<commit_msg>Fix sorted containers list in overview<commit_after>from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash, jsonify
import lxclite as lxc
import lwp
import subprocess
import time
import re
import hashlib
import signal
import sqlite3
import os
import ConfigParser

# configuration
config = ConfigParser.SafeConfigParser()
config.readfp(open('lwp.conf'))

SECRET_KEY = <KEY>

DEBUG = config.getboolean('global', 'debug')
DATABASE = config.get('database', 'file')
ADDRESS = config.get('global', 'address')
PORT = int(config.get('global', 'port'))


# Flask app
app = Flask(__name__)
app.config['TRAP_BAD_REQUEST_ERRORS'] = True
app.config.from_object(__name__)


def connect_db():
    '''
    SQLite3 connect function
    '''
    return sqlite3.connect(app.config['DATABASE'])


@app.before_request
def before_request():
    '''
    executes functions before all requests
    '''
    check_session_limit()
    g.db = connect_db()


@app.teardown_request
def teardown_request(exception):
    '''
    executes functions after all requests
    '''
    if hasattr(g, 'db'):
        g.db.close()


@app.route('/')
@app.route('/home')
def home():
    '''
    home page function
    '''
    if 'logged_in' in session:
        
        listx = lxc.listx()
        containers_all = []

        for status in ['RUNNING', 'FROZEN', 'STOPPED']:
            containers_by_status = []

            for container in listx[status]:
                containers_by_status.append({
                    'name': container,
                    'memusg': lwp.memory_usage(container),
                    'settings': lwp.get_container_settings(container)
                })
            containers_all.append({
                        'status' : status.lower(),
                        'containers' : containers_by_status
                })
{'fraction_non_alphanumeric': 0.11996757633072143, 'fraction_numerical': 0.0016211834639286678, 'mean_word_length': 2.654491609081935, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '266784', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1087, 'n_words': 261}