Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jannik Hellenkamp
website
Commits
3bfa3abe
Commit
3bfa3abe
authored
Dec 01, 2017
by
Julian Rother
Browse files
Moved handler registration to server.py to reduce module dependencies
parent
0f151bec
Changes
3
Hide whitespace changes
Inline
Side-by-side
edit.py
View file @
3bfa3abe
...
...
@@ -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
...
...
jobs.py
View file @
3bfa3abe
...
...
@@ -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
):
...
...
server.py
View file @
3bfa3abe
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment