diff --git a/edit.py b/edit.py index f9eafb7ea944f7d0dcb5e0a34578b5559661c70f..d776e06cffcf79d39471331a26753b02401650a4 100644 --- a/edit.py +++ b/edit.py @@ -119,18 +119,6 @@ def getfielddescription(path): desc = '<br>'+desc return desc -edit_handlers = {} -def edit_handler(*tables, field=None): - def wrapper(func): - for table in tables: - if table not in edit_handlers: - edit_handlers[table] = {} - if field not in edit_handlers[table]: - edit_handlers[table][field] = [] - edit_handlers[table][field].append(func) - return func - return wrapper - @app.route('/internal/edit', methods=['GET', 'POST']) @mod_required @csrf_protect diff --git a/jobs.py b/jobs.py index 0718d7d5f6cb4dd87557f813d29a3a8e8dd53eb0..509697ad50a48dc04a7e4ff2b8252a90361bfcc9 100644 --- a/jobs.py +++ b/jobs.py @@ -99,25 +99,6 @@ def jobs_worker_ping(hostname): query('REPLACE INTO worker (hostname, last_ping) values (?, ?)', hostname, datetime.now()) return 'OK',200 -job_handlers = {} -def job_handler(*types, state='finished'): - def wrapper(func): - for jobtype in types: - if jobtype not in job_handlers: - job_handlers[jobtype] = {} - if jobtype not in job_handlers[jobtype]: - job_handlers[jobtype][state] = [] - job_handlers[jobtype][state].append(func) - return func - return wrapper - -def schedule_job(jobtype, data=None, priority=0): - if not data: - data = {} - modify('INSERT INTO jobs (type, priority, data, time_created) VALUES (?, ?, ?, ?)', - jobtype, priority, json.dumps(data, default=date_json_handler), datetime.now()) - - @app.route('/internal/jobs/api/job/<int:id>/ping', methods=['GET', 'POST']) @jobs_api_token_required def jobs_ping(id): diff --git a/server.py b/server.py index fba13c72e8d33e176625dbc9a09e03cd79088bb6..5db9de319e6283abbb3c14e0dca0d9ea2a6e6f8a 100644 --- a/server.py +++ b/server.py @@ -461,14 +461,45 @@ def dbstatus(): clusters[cluster].append(host) return render_template('dbstatus.html', clusters=clusters, statuses=status, vars=variables), 200 -from edit import edit_handler + +job_handlers = {} +def job_handler(*types, state='finished'): + def wrapper(func): + for jobtype in types: + if jobtype not in job_handlers: + job_handlers[jobtype] = {} + if jobtype not in job_handlers[jobtype]: + job_handlers[jobtype][state] = [] + job_handlers[jobtype][state].append(func) + return func + return wrapper + +def schedule_job(jobtype, data=None, priority=0): + if not data: + data = {} + modify('INSERT INTO jobs (type, priority, data, time_created) VALUES (?, ?, ?, ?)', + jobtype, priority, json.dumps(data, default=date_json_handler), datetime.now()) + +edit_handlers = {} +def edit_handler(*tables, field=None): + def wrapper(func): + for table in tables: + if table not in edit_handlers: + edit_handlers[table] = {} + if field not in edit_handlers[table]: + edit_handlers[table][field] = [] + edit_handlers[table][field].append(func) + return func + return wrapper + +import edit import feeds import importer import stats if 'ICAL_URL' in config: import meetings import l2pauth -from jobs import job_handler, schedule_job +import jobs import sorter import encoding import timetable