<commit_before># -*- encoding: utf-8; py-indent-offset: 4 -*-
# +--------------------------------------------------------------------------+
# |   _____ __            ___          ______                            __  |
# |  / ___// /___  ______/ (_)___     / ____/___  ____  ____  ___  _____/ /_ |
# |  \__ \/ __/ / / / __  / / __ \   / /   / __ \/ __ \/ __ \/ _ \/ ___/ __/ |
# | ___/ / /_/ /_/ / /_/ / / /_/ /  / /___/ /_/ / / / / / / /  __/ /__/ /_   |
# |/____/\__/\__,_/\__,_/_/\____/   \____/\____/_/ /_/_/ /_/\___/\___/\__/   |
# |Copyright <NAME> 2013 - 2014 studio-connect.de                 |
# |License: BSD-2-Clause (see LICENSE File)                                  |
# +--------------------------------------------------------------------------+

from flask import Blueprint, render_template, redirect, request, url_for, flash

from app import db
from app.models.accounts import Accounts
from app.forms.accounts import AddForm, EditForm
from app import tasks
from sqlalchemy.exc import IntegrityError
import urllib3

http_small = urllib3.PoolManager(timeout=1)
mod = Blueprint('accounts', __name__, url_prefix='/accounts')


@mod.route('/')
def index():
    ipv4 = ""
    ipv6 = ""
    try:
        #ipv4= http_small.request('GET', 'http://ipv4.studio-connect.de/').data
        ipv6 = http_small.request('GET', 'http://ipv6.studio-connect.de/').data
    except:
        pass
    return render_template("accounts/index.html", accounts=accounts, ipv4=ipv4,
                           ipv6=ipv6)


@mod.route('/add/', methods=('GET', 'POST'))
def add():
    form = AddForm(request.form)
    if form.validate_on_submit():
        account = Accounts(form.data)
        db.session.add(account)
        try:
            db.session.commit()
            accounts = Accounts.query.all()
            tasks.account_config.delay(accounts)
            return redirect(url_for('accounts.index'))
        except IntegrityError:
            flash(u'IntegrityError', 'danger')
    return render_template("accounts/form.html", form=form)


@mod.route('/edit/<id>', methods=('GET', 'POST'))
def edit(id):<commit_msg>fix account error<commit_after># -*- encoding: utf-8; py-indent-offset: 4 -*-
# +--------------------------------------------------------------------------+
# |   _____ __            ___          ______                            __  |
# |  / ___// /___  ______/ (_)___     / ____/___  ____  ____  ___  _____/ /_ |
# |  \__ \/ __/ / / / __  / / __ \   / /   / __ \/ __ \/ __ \/ _ \/ ___/ __/ |
# | ___/ / /_/ /_/ / /_/ / / /_/ /  / /___/ /_/ / / / / / / /  __/ /__/ /_   |
# |/____/\__/\__,_/\__,_/_/\____/   \____/\____/_/ /_/_/ /_/\___/\___/\__/   |
# |Copyright <NAME> 2013 - 2014 studio-connect.de                 |
# |License: BSD-2-Clause (see LICENSE File)                                  |
# +--------------------------------------------------------------------------+

from flask import Blueprint, render_template, redirect, request, url_for, flash

from app import db
from app.models.accounts import Accounts
from app.forms.accounts import AddForm, EditForm
from app import tasks
from sqlalchemy.exc import IntegrityError
import urllib3

http_small = urllib3.PoolManager(timeout=1)
mod = Blueprint('accounts', __name__, url_prefix='/accounts')


@mod.route('/')
def index():
    ipv4 = ""
    ipv6 = ""
    try:
        #ipv4= http_small.request('GET', 'http://ipv4.studio-connect.de/').data
        ipv6 = http_small.request('GET', 'http://ipv6.studio-connect.de/').data
    except:
        pass
    accounts = Accounts.query.all()
    return render_template("accounts/index.html", accounts=accounts, ipv4=ipv4,
                           ipv6=ipv6)


@mod.route('/add/', methods=('GET', 'POST'))
def add():
    form = AddForm(request.form)
    if form.validate_on_submit():
        account = Accounts(form.data)
        db.session.add(account)
        try:
            db.session.commit()
            accounts = Accounts.query.all()
            tasks.account_config.delay(accounts)
            return redirect(url_for('accounts.index'))
        except IntegrityError:
            flash(u'IntegrityError', 'danger')
    return render_template("accounts/form.html", form=form)


@mod.route('/edit/<id>', methods=('GET', 'POST'))
def edit(id):
{'fraction_non_alphanumeric': 0.22667604313173934, 'fraction_numerical': 0.011251758087201125, 'mean_word_length': 1.621007371007371, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1653629', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1370, 'n_words': 209}