% for index in range(max(0, line-(max_lines-1)), min(len(lines), line+max_lines)):
${index + 1}
${lines[index] | h}
% endfor
% endif
% for (filename, lineno, function, line) in tback.reverse_traceback:
${filename}, line ${lineno}:
${line | h}
% endfor
%def>
<%def name="generate_select_options(optionArray, selectedValue=None)">
% for pair in optionArray:
<% sel = ' selected="1"' if selectedValue != None and unicode(pair[0], 'utf-8') == unicode(selectedValue, 'utf-8') else '' %> \
\
% endfor
%def>
<%def name="getSavedSearch(module, savedSearchName, useHistory=False, namespace=None, owner=None)">
<%
jsonContext = None
jobNotFoundMessage = 'Module %(module)s: Could not find a previously run search for saved search "%(savedSearchName)s".'
savedSearchNotFoundMessage = 'Module %(module)s: Could not find a saved search named "%(savedSearchName)s".'
quoteExceededMessage = 'Module %(module)s: There are too many searches running; unable to dispatch "%(savedSearchName)s".'
try :
savedSearchObject = splunk.search.getSavedSearch(
label = savedSearchName,
namespace = namespace,
owner = owner
)
jsonContext = splunk.appserver.mrsparkle.util.resurrectFromSavedSearch(
savedSearchObject = savedSearchObject,
hostPath = splunk.mergeHostPath(),
namespace = namespace,
owner = owner
)
useHistory = unicode(useHistory).capitalize()
if (useHistory in ["Auto", "None", "True"]) :
if useHistory == "None":
logger.warn("useHistory == None is being depreciated, please use Auto instead.")
try:
# Note that we never submit anything other than useHistory="true".
# this is because its problematic to let the python dispatch the search for us.
# instead if there's no job run by the scheduler, we return the other context data and let the
# client dispatch the search itself.
job = splunk.search.getJobForSavedSearch(
savedSearchName,
useHistory="True",
namespace=namespace,
owner=owner
)
if (job) :
jsonContext["job"] = job.toJsonable(timeFormat='unix')
elif useHistory == "True":
helpers.message('error', jobNotFoundMessage % {'savedSearchName': savedSearchName, 'module': module['id']})
except splunk.RESTException, e:
# Payment Required!
# Get a job by using useHistory = True
if e.statusCode == 402:
logger.warn("Could not retrieve the job history for the saved search '%s' because the current license does not allow it." % savedSearchName)
helpers.message("info", _("This view references scheduled searches that do not run automatically in Free Splunk. Please wait while they run now."))
else:
raise e
except splunk.BadRequest, e:
logger.exception(e)
if len(e.extendedMessages) > 0:
for msg in e.extendedMessages:
logger.error(msg['text'])
helpers.message(msg['type'].lower(), msg['text'])
else:
helpers.message('error', jobNotFoundMessage % {'savedSearchName': savedSearchName, 'module': module['id']})
except splunk.ResourceNotFound, e:
logger.exception(e)
helpers.message('error', savedSearchNotFoundMessage % {'savedSearchName': savedSearchName, 'module': module['id']})
except splunk.QuotaExceededException, e:
logger.warn(str(e))
helpers.message('warn', quoteExceededMessage % {'searchName': savedSearchName, 'module': module['id']})
%>
<%call expr="add_script_block()">
% if jsonContext:
Splunk.Module.loadParams.${module['id']}.jsonContext = ${jsonify(jsonContext)};
% else:
Splunk.Module.loadParams.${module['id']}.jsonContext = null;
% endif
%call>
%def>
<%def name="csrf_hidden_input()">
%def>