<?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: Where to place common python libraries in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345328#M162415</link>
    <description>&lt;P&gt;What do you mean AR app? &lt;/P&gt;</description>
    <pubDate>Sun, 11 Mar 2018 18:56:08 GMT</pubDate>
    <dc:creator>tiagofbmm</dc:creator>
    <dc:date>2018-03-11T18:56:08Z</dc:date>
    <item>
      <title>Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345323#M162410</link>
      <description>&lt;P&gt;I have multiple alert actions in Python.  I am trying to have the modalert helper for each action to load a common library, which I would like to place in this package.  I do not know where is the appropriate location within the package directory structure to place such a library.  &lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 09:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345323#M162410</guid>
      <dc:creator>eddieparra</dc:creator>
      <dc:date>2018-03-11T09:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345324#M162411</link>
      <description>&lt;P&gt;Any python library you want to add should be in:&lt;/P&gt;

&lt;P&gt;$SPLUNK_HOME/etc/apps/your_app_name/bin/lib&lt;/P&gt;

&lt;P&gt;Remember that in the lib folder, the sub-folders containing the py library must contain file &lt;STRONG&gt;init&lt;/STRONG&gt;.py&lt;/P&gt;

&lt;P&gt;Let me know if solved your question and if so, please accept the answer for future queries&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:22:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345324#M162411</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2020-09-29T18:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345325#M162412</link>
      <description>&lt;P&gt;How can I make it part of the AR app itself?  This would be more of a helper function vs. a proper library.  When using the app builder, the  bin/ directory has many mainstream libs.  I would like to embed it in a similar fashion, for all my actions.  I just don't know what is the proper location to pass validation.  Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 17:58:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345325#M162412</guid>
      <dc:creator>eddieparra</dc:creator>
      <dc:date>2018-03-11T17:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345326#M162413</link>
      <description>&lt;P&gt;Well if you put it in the app folder, under &lt;STRONG&gt;/bin/lib/&lt;/STRONG&gt; (&lt;STRONG&gt;not under /bin&lt;/STRONG&gt;) then it is part of the app. &lt;BR /&gt;
That's it!&lt;/P&gt;

&lt;P&gt;If you are planning to create an custom command in Splunk with the python library, you also need to configure commands.conf in that same app you put the python library. The python script that the command would call should be in the &lt;STRONG&gt;app folder, under /bin&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 18:11:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345326#M162413</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2018-03-11T18:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345327#M162414</link>
      <description>&lt;P&gt;Have you seen this documented anywhere?  As I look at other AR apps, I never see this.  I trust you are correct, so let me give this a try.  &lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 18:38:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345327#M162414</guid>
      <dc:creator>eddieparra</dc:creator>
      <dc:date>2018-03-11T18:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345328#M162415</link>
      <description>&lt;P&gt;What do you mean AR app? &lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 18:56:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345328#M162415</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2018-03-11T18:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345329#M162416</link>
      <description>&lt;P&gt;Adaptive Response &lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 18:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345329#M162416</guid>
      <dc:creator>eddieparra</dc:creator>
      <dc:date>2018-03-11T18:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345330#M162417</link>
      <description>&lt;P&gt;Well I believe they work the same way though. &lt;/P&gt;

&lt;P&gt;Let me know if they don't &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 19:27:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345330#M162417</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2018-03-11T19:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345331#M162418</link>
      <description>&lt;P&gt;I created the directory you stated:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME/etc/apps/your_app_name/bin/lib
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I then created:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME/etc/apps/your_app_name/bin/commands.conf.  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Inside I added:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# type of script: 'python', 'perl'
 TYPE = python

# is command streamable?
streaming = false

# maximum data that can be passed to command (0 = no limit)
maxinputs = 50000

[test_sdk]
filename = test_sdk.py
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In bin/lib I have an &lt;STRONG&gt;init&lt;/STRONG&gt;.py file and test_sdk.py&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[root@splunk lib]# ls -l
total 0
-rw-r--r--. 1 root root 0 Mar 11 12:01 __init__.py
-rw-r--r--. 1 root root 0 Mar 11 12:00 test_sdk.py
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In $SPLUNK_HOME/etc/apps/your_app_name/bin/ta__adaptive_response/, I have "modalert_blacklist_block_helper.py".  This file has "import test_sdk". &lt;/P&gt;

&lt;P&gt;When I run a test, it still can't import test_sdk.  Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:24:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345331#M162418</guid>
      <dc:creator>eddieparra</dc:creator>
      <dc:date>2020-09-29T18:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345332#M162419</link>
      <description>&lt;P&gt;I just posted a more details msg here.  It is pending moderator approval. &lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 19:29:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345332#M162419</guid>
      <dc:creator>eddieparra</dc:creator>
      <dc:date>2018-03-11T19:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345333#M162420</link>
      <description>&lt;P&gt;Two things I can see right away:&lt;/P&gt;

&lt;P&gt;1 - The commands.conf is a conf file and must be placed under  $SPLUNK_HOME/etc/apps/your_app_name/local or  $SPLUNK_HOME/etc/apps/your_app_name/default, so move it to either of the directories.&lt;/P&gt;

&lt;P&gt;2 - The test you are performing,  "import test_sdk", I suggest you first try it by using this:&lt;/P&gt;

&lt;P&gt;Go to the $SPLUNK_HOME/etc/apps/your_app_name/bin/  (&lt;STRONG&gt;where test_sdk.py must be&lt;/STRONG&gt;)&lt;/P&gt;

&lt;P&gt;Then try executing this for test:&lt;BR /&gt;
$SPLUNK_HOME/bin/splunk cmd python test_sdk.py&lt;/P&gt;

&lt;P&gt;If it still doesn't work, you need to append new directories for which python will search for modules to import, adding this to your modalert_blacklist_block_helper.py (before the import test_sdk)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import os, stat
import sys

dir = os.path.join(os.path.join(os.environ.get('SPLUNK_HOME')), 'etc', 'apps', 'your_app_name', 'bin','lib')
if not dir in sys.path:
    sys.path.append(dir)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And finally, I am not aware of the structure of having a TA inside an a Splunk App, I've never seen that before anywhere honestly, I can't judge that&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:22:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345333#M162420</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2020-09-29T18:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Where to place common python libraries</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345334#M162421</link>
      <description>&lt;P&gt;Please let me know if the answer was useful for you. If it was, accept it and upvote. If not, give us more input so we can help you with that&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:55:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-to-place-common-python-libraries/m-p/345334#M162421</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2018-03-21T16:55:02Z</dc:date>
    </item>
  </channel>
</rss>

