From c5422638a68e09b24df4afff5aa7997f486d8bf3 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Thu, 11 Jul 2019 15:22:33 +0200 Subject: [PATCH] Remove first APScheduler tests. --- app/__init__.py | 8 ------ app/scheduler/__init__.py | 5 ---- app/scheduler/forms.py | 0 app/scheduler/views.py | 39 --------------------------- app/templates/scheduler/index.html.j2 | 26 ------------------ requirements.txt | 4 +-- 6 files changed, 2 insertions(+), 80 deletions(-) delete mode 100644 app/scheduler/__init__.py delete mode 100644 app/scheduler/forms.py delete mode 100644 app/scheduler/views.py delete mode 100644 app/templates/scheduler/index.html.j2 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 %} -
-
-
- All jobs - - - - - - - - - - - - - - -
creatorfilesserviceservice_argsstatus
-
-
-
-{% endblock %} diff --git a/requirements.txt b/requirements.txt index 18b0f129..5eede513 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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