1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-14 02:47:17 +00:00

Harmonize code formatting style across project

This commit is contained in:
Kristóf Tóth 2018-06-04 21:56:59 +02:00
parent 60986fa51d
commit 12c95a198b
3 changed files with 33 additions and 15 deletions

View File

@ -2,7 +2,8 @@ from ast import literal_eval
from tornado.ioloop import IOLoop from tornado.ioloop import IOLoop
from tfw.components import IdeEventHandler, TerminalEventHandler, ProcessManagingEventHandler, BashMonitor from tfw.components import IdeEventHandler, TerminalEventHandler
from tfw.components import ProcessManagingEventHandler, BashMonitor
from tfw.components import TerminalCommands, LogMonitoringEventHandler from tfw.components import TerminalCommands, LogMonitoringEventHandler
from tfw.networking import MessageSender, TFWServerConnector from tfw.networking import MessageSender, TFWServerConnector
from tfw.config import TFWENV from tfw.config import TFWENV
@ -54,8 +55,10 @@ class TestCommands(TerminalCommands):
This can speed up development when combined with mounting This can speed up development when combined with mounting
volumes from host to container. volumes from host to container.
""" """
seppuku = ('nohup sh -c "supervisorctl restart tfwserver event_handler_main" &> /dev/null & ' seppuku = (
'clear && echo "Committed seppuku! :)" && sleep infinity') 'nohup sh -c "supervisorctl restart tfwserver event_handler_main" &> /dev/null & '
'clear && echo "Committed seppuku! :)" && sleep infinity'
)
uplink = TFWServerConnector() uplink = TFWServerConnector()
uplink.send_to_eventhandler({ uplink.send_to_eventhandler({
'key': 'shell', 'key': 'shell',

View File

@ -6,9 +6,11 @@ from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///db.db', convert_unicode=True) engine = create_engine('sqlite:///db.db', convert_unicode=True)
session_factory = sessionmaker(autocommit=False, session_factory = sessionmaker(
autoflush=False, autocommit=False,
bind=engine) autoflush=False,
bind=engine
)
@contextmanager @contextmanager

View File

@ -10,7 +10,9 @@ BASEURL = getenv('BASEURL', '')
init_db() init_db()
app = Flask(__name__) app = Flask(__name__)
app.secret_key = urandom(32) app.secret_key = urandom(32)
app.jinja_env.globals.update(get_url=lambda endpoint: f'{BASEURL}{url_for(endpoint)}') # pylint: disable=no-member app.jinja_env.globals.update( # pylint: disable=no-member
get_url=lambda endpoint: f'{BASEURL}{url_for(endpoint)}'
)
def get_db_session(): def get_db_session():
@ -47,22 +49,33 @@ def index():
@app.route('/register', methods=['GET', 'POST']) @app.route('/register', methods=['GET', 'POST'])
def register(): def register():
if request.method == 'POST': if request.method == 'POST':
if not all([request.form.get('username'), form_filled_out = all([
request.form.get('password'), request.form.get('username'),
request.form.get('passwordconfirm')]): request.form.get('password'),
request.form.get('passwordconfirm')
])
if not form_filled_out:
return render_template('register.html', alert='You need to fill everything.') return render_template('register.html', alert='You need to fill everything.')
if request.form['password'] != request.form['passwordconfirm']: if request.form['password'] != request.form['passwordconfirm']:
return render_template('register.html', alert='Passwords do not match! Please try again.') return render_template('register.html', alert='Passwords do not match! Please try again.')
try: try:
UserOps(request.form.get('username'), UserOps(
request.form.get('password'), request.form.get('username'),
get_db_session()).register() request.form.get('password'),
get_db_session()
).register()
except UserExistsError: except UserExistsError:
return render_template('register.html', alert='Username already in use.') return render_template('register.html', alert='Username already in use.')
return render_template('login.html', success=('Account "{}" successfully registered. ' return render_template(
'You can log in now!'.format(request.form['username']))) 'login.html',
success=(
'Account "{}" successfully registered. '
'You can log in now!'.format(request.form['username'])
)
)
return render_template('register.html') return render_template('register.html')