Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mutalyzer
mutalyzer2
Commits
5867693b
Commit
5867693b
authored
Nov 04, 2015
by
Vermaat
Browse files
Fix link in batch notification if submitted from webservice
parent
09c2755a
Changes
6
Hide whitespace changes
Inline
Side-by-side
doc/config.rst
View file @
5867693b
...
...
@@ -184,6 +184,14 @@ REVERSE_PROXIED
`Default value:` `False`
.. _config-website-root-url:
WEBSITE_ROOT_URL
URL to the website root (without trailing slash). Used for generating
download links in the batch scheduler.
`Default value:` `None`
.. _config-soap-wsdl-url:
SOAP_WSDL_URL
...
...
doc/deploy.rst
View file @
5867693b
...
...
@@ -30,6 +30,7 @@ settings:
- :ref:`EMAIL <config-email>`
- :ref:`DEBUG <config-debug>`
- :ref:`CACHE_DIR <config-cache-dir>`
- :ref:`WEBSITE_ROOT_URL <config-website-root-url>`
- :ref:`SOAP_WSDL_URL <config-soap-wsdl-url>`
- :ref:`JSON_ROOT_URL <config-json-root-url>`
- :ref:`REVERSE_PROXIED <config-reverse-proxied>`
...
...
mutalyzer/Scheduler.py
View file @
5867693b
...
...
@@ -33,6 +33,7 @@ from mutalyzer.grammar import Grammar
from
mutalyzer.output
import
Output
from
mutalyzer.mapping
import
Converter
from
mutalyzer
import
Retriever
# Retriever.Retriever
from
mutalyzer
import
website
__all__
=
[
"Scheduler"
]
...
...
@@ -83,7 +84,7 @@ class Scheduler() :
return
not
self
.
__run
#stopped
def
__sendMail
(
self
,
mailTo
,
url
)
:
def
__sendMail
(
self
,
mailTo
,
result_id
)
:
"""
Send an e-mail containing an url to a batch job submitter.
...
...
@@ -91,8 +92,8 @@ class Scheduler() :
@arg mailTo: The batch job submitter
@type mailTo: unicode
@arg
url: The url containing
the result
s
@type
url
: unicode
@arg
result_id: Identifier for
the
job
result
.
@type
result_id
: unicode
"""
if
settings
.
TESTING
:
return
...
...
@@ -105,6 +106,9 @@ class Scheduler() :
#TODO: Handle Connection errors in a try, except clause
#Expected errors: socket.error
download_url
=
website
.
url_for
(
'batch_job_result'
,
result_id
=
result_id
)
message
=
MIMEText
(
"""Dear submitter,
The batch operation you have submitted, has been processed successfully.
...
...
@@ -116,7 +120,7 @@ Thanks for using Mutalyzer.
With kind regards,
Mutalyzer batch scheduler"""
%
url
)
Mutalyzer batch scheduler"""
%
download_
url
)
message
[
"Subject"
]
=
"Result of your Mutalyzer batch job"
message
[
"From"
]
=
settings
.
EMAIL
...
...
@@ -403,7 +407,7 @@ Mutalyzer batch scheduler""" % url)
else
:
print
(
'Job %s finished, email %s file %s'
%
(
batch_job
.
id
,
batch_job
.
email
,
batch_job
.
id
))
self
.
__sendMail
(
batch_job
.
email
,
batch_job
.
download_url
)
self
.
__sendMail
(
batch_job
.
email
,
batch_job
.
result_id
)
session
.
delete
(
batch_job
)
session
.
commit
()
#process
...
...
@@ -729,8 +733,7 @@ Mutalyzer batch scheduler""" % url)
"Finished SNP converter batch rs%s"
%
cmd
)
#_processSNP
def
addJob
(
self
,
email
,
queue
,
columns
,
job_type
,
argument
=
None
,
create_download_url
=
None
):
def
addJob
(
self
,
email
,
queue
,
columns
,
job_type
,
argument
=
None
):
"""
Add a job to the Database and start the BatchChecker.
...
...
@@ -744,18 +747,12 @@ Mutalyzer batch scheduler""" % url)
@type job_type:
@arg argument: Batch Arguments, for now only build info
@type argument:
@arg create_download_url: Function accepting a result_id and returning
the URL for downloading the batch job
result. Can be None.
@type create_download_url: function
@return: result_id
@rtype:
"""
# Add jobs to the database
batch_job
=
BatchJob
(
job_type
,
email
=
email
,
argument
=
argument
)
if
create_download_url
:
batch_job
.
download_url
=
create_download_url
(
batch_job
.
result_id
)
session
.
add
(
batch_job
)
for
i
,
inputl
in
enumerate
(
queue
):
...
...
mutalyzer/config/default_settings.py
View file @
5867693b
...
...
@@ -69,6 +69,10 @@ BATCH_JOBS_ERROR_THRESHOLD = 0.05
# (in seconds).
NEGATIVE_LINK_CACHE_EXPIRATION
=
60
*
60
*
24
*
30
# URL to the website root (without trailing slash). Used for generating
# download links in the batch scheduler.
WEBSITE_ROOT_URL
=
None
# URL to the SOAP webservice WSDL document. Used to build the WSDL document
# and for linking to it from the documentation page on the website.
SOAP_WSDL_URL
=
None
...
...
mutalyzer/website/__init__.py
View file @
5867693b
...
...
@@ -8,6 +8,7 @@ from __future__ import unicode_literals
import
logging
import
os
import
pkg_resources
import
urlparse
from
flask
import
Flask
...
...
@@ -46,3 +47,22 @@ def create_app():
session
.
remove
()
return
app
def
url_for
(
endpoint
,
**
values
):
"""
Generates a URL to the given website endpoint.
Like :func:`Flask.url_for`, but for when you don't have an application or
request context.
Note that the generated URL will be based on the `WEBSITE_ROOT_URL`
configuration setting or `http://localhost` if not set.
:arg str endpoint: The endpoint of the URL (name of the function).
:arg str values: The variable arguments of the URL rule.
"""
root
=
urlparse
.
urlsplit
(
settings
.
WEBSITE_ROOT_URL
or
'http://localhost'
)
url_map
=
create_app
().
url_map
.
bind
(
root
.
netloc
,
root
.
path
or
'/'
,
url_scheme
=
root
.
scheme
)
return
url_map
.
build
(
'website.%s'
%
endpoint
,
values
,
force_external
=
True
)
mutalyzer/website/views.py
View file @
5867693b
...
...
@@ -937,15 +937,8 @@ def batch_jobs_submit():
errors
.
append
(
'Could not parse input file, please check your '
'file format.'
)
else
:
# Creates the result download URL from a job result_id.
def
create_download_url
(
result_id
):
return
url_for
(
'.batch_job_result'
,
result_id
=
result_id
,
_external
=
True
)
result_id
=
scheduler
.
addJob
(
email
,
job
,
columns
,
job_type
,
argument
=
argument
,
create_download_url
=
create_download_url
)
result_id
=
scheduler
.
addJob
(
email
,
job
,
columns
,
job_type
,
argument
=
argument
)
# Todo: We now assume that the job was not scheduled if there are
# messages, which is probably not correct.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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