Yep, that's a good suggestion. Can you either please file a ticket on github.com/ansible/ansible or submit a pull request that changes the docs (.rst files in the code tree) to say something like "timecheck" ?
I think this ordinarily won't happen anyway, but the module happened to be in your PYTHON_PATH. Usually this wouldn't be the case but it would be nice to step around the possible confusion for others finding this in the dev docs. Appreciate the heads up! On Thu, Oct 30, 2014 at 3:07 PM, Matt Martz <[email protected]> wrote: > Since "time" is part of the Python standard library and it is imported > from various places within ansible you should not have a module > named time.py since puthon will try to use that file as the file to satisfy > "import time". > > This wouldn't have been a problem before modules had .py extensions. I > imagine the docs should probably be updated to name this something other > than time.py > > > On Thursday, October 30, 2014, Tiglath <[email protected]> wrote: > >> I followed the docs example to add a module as with the time.py example. >> >> So I have: >> ----------- >> #!/usr/bin/python >> >> import datetime >> import json >> >> date = str(datetime.datetime.now()) >> print json.dumps({ >> "time" : date >> }) >> ----------- >> >> And after: >> >> source ansible/hacking/env-setup >> chmod +x ansible/hacking/test-module >> ansible/hacking/test-module -m ./time.py >> >> I get: >> >> >> {"time": "2014-10-30 14:34:22.224548"} >> >> Traceback (most recent call last): >> >> File "ansible-dev/hacking/test-module", line 37, in <module> >> >> import ansible.utils as utils >> >> File >> "/export/home/jsuriol/.local/lib/python2.6/site-packages/ansible-1.8-py2.6.egg/ansible/utils/__init__.py", >> line 29, in <module> >> >> from ansible.utils.display_functions import * >> >> File >> "/export/home/jsuriol/.local/lib/python2.6/site-packages/ansible-1.8-py2.6.egg/ansible/utils/display_functions.py", >> line 22, in <module> >> >> from ansible.callbacks import display >> >> File >> "/export/home/jsuriol/.local/lib/python2.6/site-packages/ansible-1.8-py2.6.egg/ansible/callbacks.py", >> line 31, in <module> >> >> import logging >> >> File "/usr/lib/python2.6/logging/__init__.py", line 89, in <module> >> >> _startTime = time.time() >> >> AttributeError: 'module' object has no attribute 'time' >> >> ------- >> >> The file logging/__init__.py imports time, so what can the problem be? >> >> >> >> Thanks >> >> >> >> >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/78ba5eaa-226c-412c-8df9-559014c722e0%40googlegroups.com >> <https://groups.google.com/d/msgid/ansible-project/78ba5eaa-226c-412c-8df9-559014c722e0%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Matt Martz > @sivel > sivel.net > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAD8N0v_9uztnrH-KP3z1HVoMJ0_A%3DqcjvGq3FuQUZaQGQLhXPA%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAD8N0v_9uztnrH-KP3z1HVoMJ0_A%3DqcjvGq3FuQUZaQGQLhXPA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgxwExhWO-wynu-MXbEFmSs3dVymhDvLyov6jSNUcdYjNA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
