diff --git a/app/__init__.py b/app/__init__.py index f530b4d5..7b4f60ad 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -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 diff --git a/app/scheduler/__init__.py b/app/scheduler/__init__.py deleted file mode 100644 index 447f8f5e..00000000 --- a/app/scheduler/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from flask import Blueprint - -scheduler = Blueprint('scheduler', __name__) - -from . import views diff --git a/app/scheduler/forms.py b/app/scheduler/forms.py deleted file mode 100644 index e69de29b..00000000 diff --git a/app/scheduler/views.py b/app/scheduler/views.py deleted file mode 100644 index a74f6695..00000000 --- a/app/scheduler/views.py +++ /dev/null @@ -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) diff --git a/app/templates/scheduler/index.html.j2 b/app/templates/scheduler/index.html.j2 deleted file mode 100644 index aaa3a40b..00000000 --- a/app/templates/scheduler/index.html.j2 +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "base.html.j2" %} - -{% block page_content %} -
creator | -files | -service | -service_args | -status | -
---|