<?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 How can I import croniter in my modular input? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-import-croniter-in-my-modular-input/m-p/369536#M6023</link>
    <description>&lt;P&gt;I want to accept data input interval as cron entry and process it in my modular input. &lt;BR /&gt;
I am referring this REST API Modular Input app (&lt;A href="https://splunkbase.splunk.com/app/1546/" target="_blank"&gt;https://splunkbase.splunk.com/app/1546/&lt;/A&gt;) for that. It uses croniter to get next run time of job. &lt;/P&gt;

&lt;P&gt;However, I am not being able to import croniter into my modular input script. &lt;BR /&gt;
I have croniter egg file at SPLUNK_HOME/etc/apps/TA-myta/bin/croniter-0.3.8-py2.7.egg&lt;BR /&gt;
I have also explicitly added SPLUNK_HOME/etc/apps/TA-myta/bin/croniter-0.3.8-py2.7.egg to sys.path (not needed, but added as an attempt to make it work.)&lt;BR /&gt;
However, when I try to import croniter, I get ImportError. &lt;/P&gt;

&lt;P&gt;How can I fix this?&lt;/P&gt;

&lt;P&gt;My code to the point of failure looks as follows. I always get into except block and never see "ready to go":&lt;BR /&gt;
    import sys&lt;BR /&gt;
    from datetime import datetime&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunk.clilib.cli_common as scc
import splunk.entity as entity

logger = logging.getLogger('TA-myta')

TA_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

egg_dir = TA_ROOT + "/bin/croniter-0.3.8-py2.7.egg"
sys.path.append(egg_dir)
try:
    from croniter import croniter
except:
    logger.error("could not import croniter. Exiting.")
    exit(0)

logger.info("ready to go")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit 1:&lt;BR /&gt;
The splunkd.log has following lines:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;03-22-2017 16:27:30.105 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py" ImportError: No module named dateutil.relativedelta
03-22-2017 16:28:30.264 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py" Traceback (most recent call last):
03-22-2017 16:28:30.264 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"   File "/opt/splunk/etc/apps/TA-myta/bin/myta.py", line 39, in &amp;lt;module&amp;gt;
03-22-2017 16:28:30.265 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"     from croniter import croniter
03-22-2017 16:28:30.265 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"   File "/opt/splunk/etc/apps/TA-myta/bin/croniter-0.3.8-py2.7.egg/croniter/__init__.py", line 3, in &amp;lt;module&amp;gt;
03-22-2017 16:28:30.265 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"     import abc
03-22-2017 16:28:30.265 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"   File "/opt/splunk/etc/apps/TA-myta/bin/croniter-0.3.8-py2.7.egg/croniter/croniter.py", line 8, in &amp;lt;module&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 13:19:24 GMT</pubDate>
    <dc:creator>prabhasgupte</dc:creator>
    <dc:date>2020-09-29T13:19:24Z</dc:date>
    <item>
      <title>How can I import croniter in my modular input?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-import-croniter-in-my-modular-input/m-p/369536#M6023</link>
      <description>&lt;P&gt;I want to accept data input interval as cron entry and process it in my modular input. &lt;BR /&gt;
I am referring this REST API Modular Input app (&lt;A href="https://splunkbase.splunk.com/app/1546/" target="_blank"&gt;https://splunkbase.splunk.com/app/1546/&lt;/A&gt;) for that. It uses croniter to get next run time of job. &lt;/P&gt;

&lt;P&gt;However, I am not being able to import croniter into my modular input script. &lt;BR /&gt;
I have croniter egg file at SPLUNK_HOME/etc/apps/TA-myta/bin/croniter-0.3.8-py2.7.egg&lt;BR /&gt;
I have also explicitly added SPLUNK_HOME/etc/apps/TA-myta/bin/croniter-0.3.8-py2.7.egg to sys.path (not needed, but added as an attempt to make it work.)&lt;BR /&gt;
However, when I try to import croniter, I get ImportError. &lt;/P&gt;

&lt;P&gt;How can I fix this?&lt;/P&gt;

&lt;P&gt;My code to the point of failure looks as follows. I always get into except block and never see "ready to go":&lt;BR /&gt;
    import sys&lt;BR /&gt;
    from datetime import datetime&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunk.clilib.cli_common as scc
import splunk.entity as entity

logger = logging.getLogger('TA-myta')

TA_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

egg_dir = TA_ROOT + "/bin/croniter-0.3.8-py2.7.egg"
sys.path.append(egg_dir)
try:
    from croniter import croniter
except:
    logger.error("could not import croniter. Exiting.")
    exit(0)

logger.info("ready to go")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit 1:&lt;BR /&gt;
The splunkd.log has following lines:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;03-22-2017 16:27:30.105 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py" ImportError: No module named dateutil.relativedelta
03-22-2017 16:28:30.264 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py" Traceback (most recent call last):
03-22-2017 16:28:30.264 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"   File "/opt/splunk/etc/apps/TA-myta/bin/myta.py", line 39, in &amp;lt;module&amp;gt;
03-22-2017 16:28:30.265 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"     from croniter import croniter
03-22-2017 16:28:30.265 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"   File "/opt/splunk/etc/apps/TA-myta/bin/croniter-0.3.8-py2.7.egg/croniter/__init__.py", line 3, in &amp;lt;module&amp;gt;
03-22-2017 16:28:30.265 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"     import abc
03-22-2017 16:28:30.265 +0530 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/TA-myta/bin/myta.py"   File "/opt/splunk/etc/apps/TA-myta/bin/croniter-0.3.8-py2.7.egg/croniter/croniter.py", line 8, in &amp;lt;module&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:19:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-import-croniter-in-my-modular-input/m-p/369536#M6023</guid>
      <dc:creator>prabhasgupte</dc:creator>
      <dc:date>2020-09-29T13:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import croniter in my modular input?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-import-croniter-in-my-modular-input/m-p/369537#M6024</link>
      <description>&lt;P&gt;Never mind! Got it working!!&lt;/P&gt;

&lt;P&gt;I needed to add and import eggs for python_dateutil and six - as dependencies for croniter. &lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 12:19:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-import-croniter-in-my-modular-input/m-p/369537#M6024</guid>
      <dc:creator>prabhasgupte</dc:creator>
      <dc:date>2017-03-22T12:19:20Z</dc:date>
    </item>
  </channel>
</rss>

