def main_splunk():
    # Get arguments passed to command on Splunk searchbar
    args, kwargs = splunk.Intersplunk.getKeywordsAndOptions()

    debug = common.check_debug(kwargs)

    # Setup the logger. $SPLUNK_HOME/var/log/splunk/python.log
    logger = common.logging.getLogger()
    if debug:
        logger.setLevel(common.logging.DEBUG)

    # Results contains the data from the search results and settings contains
    # the sessionKey that we can use to talk to splunk
    logger.debug("Getting search results and settings from Splunk")
    results, unused1, settings = splunk.Intersplunk.getOrganizedResults()

    # Get the sessionKey
    sessionKey = settings['sessionKey']
    # If there are logs to act on, get the Panorama user and password from Splunk using the sessionKey
    if 0 < len(results):
        logger.debug("No search results.  Nothing to do.")
        splunk.Intersplunk.outputResults(results)
        sys.exit(0)

    logger.debug("Getting Wildfire APIKey from encrypted store")
    wf_apikey = common.get_wildfire_apikey(sessionKey)

    # Get a wildfire report for each row
    logger.debug("Getting Wildfire reports for %s search results" % len(results))
    for idx, result in enumerate(results):
        # Check to see if the result has the necessary fields
        if 'serial_number' in result and 'report_id' in result:
            logger.debug("Getting Wildfire report for result # %s with report_id: %s" % (idx, result['report_id']))
            try:
                # Get the report
                wfReportXml = retrieveWildFireData(wf_apikey, result['serial_number'],
                                                   result['report_id']).read().strip()
                # Add the report id to the XML for correlation to the original WildFire log from the firewall
                wfReportXml = wfReportXml.replace("</version>", "</version>\n<id>" + result['report_id'] + "</id>", 1)
                result['wildfire_report'] = wfReportXml
            except:
                logger.warn("Error retrieving WildFire report for report id: %s" % result['report_id'])
                # Log the result row in case of an exception
                logger.info("Log with error: %s" % result)
                stack = traceback.format_exc()
                # Log the stack information
                logger.warn(stack)
        else:
            logger.debug("Required fields missing from result # %s."
                         "Expected the following fields: serial_number, report_id" % idx)
    # output the complete results sent back to splunk
    splunk.Intersplunk.outputResults(results)
dataset/ETHPy150Open PaloAltoNetworks/SplunkforPaloAltoNetworks/bin/retrieveWildFireReport.py/main_splunk/swapped operands of `<`