Remove first APScheduler tests.

This commit is contained in:
Patrick Jentsch 2019-07-11 15:22:33 +02:00
parent 0266886874
commit c5422638a6
6 changed files with 2 additions and 80 deletions

View File

@ -1,4 +1,3 @@
from apscheduler.schedulers.background import BackgroundScheduler
from config import config
from flask import Flask
from flask_login import LoginManager
@ -13,8 +12,6 @@ login_manager.login_view = 'auth.login'
mail = Mail()
background_scheduler = BackgroundScheduler()
def create_app(config_name):
app = Flask(__name__)
@ -31,9 +28,4 @@ def create_app(config_name):
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
from .scheduler import scheduler as scheduler_blueprint
app.register_blueprint(scheduler_blueprint, url_prefix='/scheduler')
background_scheduler.start()
return app

View File

@ -1,5 +0,0 @@
from flask import Blueprint
scheduler = Blueprint('scheduler', __name__)
from . import views

View File

View File

@ -1,39 +0,0 @@
from flask import render_template
from . import scheduler
from flask_login import current_user, login_required
from .. import background_scheduler
import json
import subprocess
@scheduler.route('/')
@login_required
def scheduler():
job = {
'creator': current_user.id,
'files': ['file_1', 'file_2', 'file_3'],
'service': 'ocr',
'service_args': {
'lang': 'deu'
},
'status': 'queued'
}
job = background_scheduler.add_job(process_job, trigger='date', args=[job])
print('### New job added for scheduling ###')
print(job)
return render_template('scheduler/index.html.j2', title='Scheduler')
def process_job(job):
input_dir = '/home/pjentsch/%s/input' % job['service']
output_dir = '/home/pjentsch/%s/output' % job['service']
job['status'] = 'running'
print('### Job status changed ###')
print(job)
subprocess.run([job['service'], '-i', input_dir, '-l', job['service_args']['lang'], '-o', output_dir, '--keep-intermediates'])
job['status'] = 'finished'
print('### Job status changed ###')
print(job)

View File

@ -1,26 +0,0 @@
{% extends "base.html.j2" %}
{% block page_content %}
<div class="col s12">
<div class="card">
<div class="card-content">
<span class="card-title">All jobs</span>
<table>
<thead>
<tr>
<th>creator</th>
<th>files</th>
<th>service</th>
<th>service_args</th>
<th>status</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,9 +1,9 @@
APScheduler==3.6.0
Flask==1.0.3
Flask-APScheduler==1.11.0
Flask-Login==0.4.1
Flask-Mail==0.9.1
Flask-Migrate==2.5.2
Flask-SQLAlchemy==2.4.0
Flask-Table==0.5.0
Flask-WTF==0.14.2
python-dotenv==0.10.3
Flask-Table==0.5.0