mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-13 01:20:41 +00:00
Move ocr job to extra package.
This commit is contained in:
@ -1,6 +0,0 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import SubmitField
|
||||
|
||||
|
||||
class SwarmForm(FlaskForm):
|
||||
submit = SubmitField('Submit')
|
||||
|
@ -1,12 +1,9 @@
|
||||
from flask import redirect, render_template, url_for
|
||||
from flask import render_template
|
||||
from ..models import User
|
||||
from ..tables import AdminUserTable, AdminUserItem
|
||||
from . import main
|
||||
from ..decorators import admin_required
|
||||
from flask_login import current_user, login_required
|
||||
from .forms import SwarmForm
|
||||
from ..import swarm
|
||||
from threading import Thread
|
||||
from flask_login import login_required
|
||||
|
||||
|
||||
@main.route('/')
|
||||
@ -29,32 +26,5 @@ def for_admins_only():
|
||||
users = User.query.order_by(User.username).all()
|
||||
items = [AdminUserItem(u.username, u.email, u.role_id, u.confirmed) for u in users]
|
||||
table = AdminUserTable(items)
|
||||
|
||||
swarm_form = SwarmForm()
|
||||
if swarm_form.validate_on_submit():
|
||||
'''
|
||||
' TODO: Implement a Job class. For now a dictionary representation is
|
||||
' enough.
|
||||
'''
|
||||
job = {
|
||||
'creator': current_user.id,
|
||||
'id': '5fd40cb0cadef3ab5676c4968fc3d748',
|
||||
'requested_cpus': 2,
|
||||
'requested_memory': 2048,
|
||||
'service': 'ocr',
|
||||
'service_args': {
|
||||
'lang': 'eng'
|
||||
},
|
||||
'status': 'queued'
|
||||
}
|
||||
'''
|
||||
' TODO: Let the scheduler run this job in the background. Using self
|
||||
' created threads is just for testing purpose as there is no
|
||||
' scheduler available.
|
||||
'''
|
||||
thread = Thread(target=swarm.run, args=(job,))
|
||||
thread.start()
|
||||
return redirect(url_for('main.for_admins_only'))
|
||||
|
||||
return render_template('main/admin.html.j2', title='Administration tools',
|
||||
swarm_form=swarm_form, table=table.__html__())
|
||||
table=table.__html__())
|
||||
|
Reference in New Issue
Block a user