mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
41 lines
998 B
Python
41 lines
998 B
Python
from . import db
|
|
from .models import Corpus, Role
|
|
from flask_migrate import upgrade
|
|
|
|
|
|
def register(app):
|
|
@app.cli.command()
|
|
def deploy():
|
|
"""Run deployment tasks."""
|
|
# migrate database to latest revision
|
|
upgrade()
|
|
# create or update user roles
|
|
Role.insert_roles()
|
|
|
|
@app.cli.group()
|
|
def daemon():
|
|
"""Daemon commands."""
|
|
pass
|
|
|
|
@daemon.command('run')
|
|
def run_daemon():
|
|
"""Run daemon"""
|
|
for corpus in Corpus.query.filter(Corpus.num_analysis_sessions > 0):
|
|
corpus.num_analysis_sessions = 0
|
|
db.session.commit()
|
|
from app.daemon import Daemon
|
|
daemon = Daemon()
|
|
daemon.run()
|
|
|
|
@app.cli.group()
|
|
def test():
|
|
"""Test commands."""
|
|
pass
|
|
|
|
@test.command('run')
|
|
def run_test():
|
|
"""Run unit tests."""
|
|
import unittest
|
|
tests = unittest.TestLoader().discover('tests')
|
|
unittest.TextTestRunner(verbosity=2).run(tests)
|