<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can I get the current app from Python? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Can-I-get-the-current-app-from-Python/m-p/68774#M950</link>
    <description>&lt;P&gt;I am writing a custom search command.  Looks like the last option you presented may be the one.  I will give it a shot.  Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2013 03:26:16 GMT</pubDate>
    <dc:creator>timpgray</dc:creator>
    <dc:date>2013-03-22T03:26:16Z</dc:date>
    <item>
      <title>Can I get the current app from Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Can-I-get-the-current-app-from-Python/m-p/68772#M948</link>
      <description>&lt;P&gt;I notice there is a method to get the current apps dir from python.  There is also a getCurrentApp() available in javascript, but I need the current app from Python.&lt;/P&gt;

&lt;P&gt;Does anyone have any suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 20:51:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Can-I-get-the-current-app-from-Python/m-p/68772#M948</guid>
      <dc:creator>timpgray</dc:creator>
      <dc:date>2013-03-20T20:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Can I get the current app from Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Can-I-get-the-current-app-from-Python/m-p/68773#M949</link>
      <description>&lt;P&gt;Which type of python file?  We tend to use python's &lt;CODE&gt;__file__&lt;/CODE&gt; attribute.  I assume that you have imported os and cherrypy at least.&lt;/P&gt;

&lt;P&gt;For example, in the file $SPLUNK_HOME/etc/apps/TA-opseclea/appserver/controllers/:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; app_name = __file__.split('.')[-2]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I was implementing a controller method where a request was routed to me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;@route('/:app/:action=edit/:name')
@expose_page(must_login=True, methods=['GET']) 
def edit(self, app, action, name, **kwargs):
    host_app = cherrypy.request.path_info.split('/')[3]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For a scripted input in an app's .\bin directory:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;app_name = __file__.split(os.sep)[-3]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Mar 2013 22:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Can-I-get-the-current-app-from-Python/m-p/68773#M949</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2013-03-21T22:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can I get the current app from Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Can-I-get-the-current-app-from-Python/m-p/68774#M950</link>
      <description>&lt;P&gt;I am writing a custom search command.  Looks like the last option you presented may be the one.  I will give it a shot.  Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 03:26:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Can-I-get-the-current-app-from-Python/m-p/68774#M950</guid>
      <dc:creator>timpgray</dc:creator>
      <dc:date>2013-03-22T03:26:16Z</dc:date>
    </item>
  </channel>
</rss>

