mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 12:13:33 +08:00
Switch biostars to using HTML submission
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"""The module describes the ``biostars`` error sink plugin."""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
from galaxy.tools.errors import EmailErrorReporter
|
||||
from galaxy.util import string_as_bool
|
||||
from galaxy.util import biostar
|
||||
from galaxy.web.base.controller import url_for
|
||||
|
||||
|
||||
from ..sinks import ErrorSinkPlugin
|
||||
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
|
||||
class BiostarsPlugin( ErrorSinkPlugin ):
|
||||
"""Send error report as an issue on Biostars
|
||||
"""
|
||||
plugin_type = "biostars"
|
||||
|
||||
def __init__( self, **kwargs ):
|
||||
self.app = kwargs['app']
|
||||
self.verbose = string_as_bool(kwargs.get('verbose', True))
|
||||
self.user_submission = string_as_bool(kwargs.get('user_submission', True))
|
||||
|
||||
def submit_report( self, dataset, job, tool, **kwargs ):
|
||||
"""Send report as an email
|
||||
"""
|
||||
try:
|
||||
assert biostar.biostar_enabled( self.app ), ValueError( "Biostar is not configured for this galaxy instance" )
|
||||
assert self.app.config.biostar_enable_bug_reports, ValueError( "Biostar is not configured to allow bug reporting for this galaxy instance" )
|
||||
print(kwargs)
|
||||
|
||||
url = url_for(controller='biostar',
|
||||
action='biostar_tool_bug_report',
|
||||
hda=self.app.security.encode_id(dataset.id),
|
||||
email=kwargs['email'], message=kwargs['message'])
|
||||
return ( 'Click <a href="%s">here</a> to submit to BioStars' % url, 'success' )
|
||||
except Exception as e:
|
||||
return ( "An error occurred submitting the report to biostars: %s" % str( e ), "danger" )
|
||||
|
||||
|
||||
__all__ = ( 'BiostarsPlugin', )
|
||||
@@ -169,7 +169,20 @@ class BiostarErrorReporter( ErrorReporter ):
|
||||
assert self._can_access_dataset( user ), Exception( "You are not allowed to access this dataset." )
|
||||
tool_version_select_field, tools, tool = \
|
||||
self.app.toolbox.get_tool_components( self.tool_id, tool_version=None, get_loaded_tools_by_lineage=False, set_selected=True )
|
||||
payload = { 'title': 'Bug report on "%s" tool' % ( tool.name ), 'content': self.report.replace( '\n', '<br />' ).replace( '\r', '' ), 'tag_val': slugify( 'bug report' ) }
|
||||
|
||||
# Strip out unwanted HTML characters
|
||||
html_remove = ['<html>', '<body>', '</body>', '</html>', '\n', '\r']
|
||||
report = self.html_report
|
||||
for tag in html_remove:
|
||||
report = report.replace(tag, '')
|
||||
# Must lstrip spaces or it isn't recognised as HTML
|
||||
report = report.lstrip()
|
||||
|
||||
payload = {
|
||||
'title': 'Bug report on "%s" tool' % ( tool.name ),
|
||||
'content': report,
|
||||
'tag_val': slugify( 'bug report' )
|
||||
}
|
||||
# Get footer for email from here
|
||||
payload2 = populate_tool_payload( tool=tool )
|
||||
if 'content' in payload2:
|
||||
|
||||
Reference in New Issue
Block a user