Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not any file named q #53

Open
alonsocamaro opened this issue Apr 24, 2018 · 7 comments
Open

Not any file named q #53

alonsocamaro opened this issue Apr 24, 2018 · 7 comments

Comments

@alonsocamaro
Copy link

Hi

using q in an ansible module as follows:

    def exec_module(self):
        changed = False
        result = dict()
        state = self.want.state
        import q
        q.q(state)

There is no file q created anywhere in the file system...

[root@ansible-tower-32 library]# find / -type f -name q -print | wc -l
0

I reckon this is a problem between the chair and the keyboard.... any tip would be more than welcome

Thanks!

     Ulises
@jhermann
Copy link

q.py[co]

@alonsocamaro
Copy link
Author

alonsocamaro commented Apr 24, 2018

@jhermann I don't know what you mean....

In any case, if I do the following simple test it does work from outside Ansible Tower

[root@ansible-tower-32 library]# python
Python 2.7.5 (default, Feb 20 2018, 09:19:12) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import q
>>> something = "test"
>>> q.q(something)
'test'
>>> 
[root@ansible-tower-32 library]# ls -l /tmp/q
-rw-r--r--. 1 root root 42 Apr 24 08:56 /tmp/q
[root@ansible-tower-32 library]# cat /tmp/q

15.0s <module>: 'test'

@hroncok
Copy link

hroncok commented Apr 30, 2018

try decorating def exec_module with q to see if it's even called.

@howardjones
Copy link

howardjones commented Dec 6, 2021

@alonsocamaro did you get this to work in the end? I'm trying to use q to trace an ansible module, and so far it's just adding to the confusion.

Adding @q decorator to all the module's internal methods seems to result in /tmp/q just listing them all. Using @q.t gives the expected parameters etc in the file, but only for some calls (I can see from behaviour that some of the trace functions are being called but not logged).

I really want this to work - debugging ansible is horrible!

(so, for the @q case, I get something like this, which is just a list of all the functions in the module - there is no code path that will actually run them in this order)

0.2s AzureRMEventGridSubscription: 
      <function AzureRMEventGridSubscription.exec_module>
 0.2s AzureRMEventGridSubscription: 
      <function AzureRMEventGridSubscription.get_eventgrid_client>
 0.2s AzureRMEventGridSubscription: 
      <function AzureRMEventGridSubscription.get_subscription>
 0.2s AzureRMEventGridSubscription: 
      <function AzureRMEventGridSubscription.create_update_subscription>
 0.2s AzureRMEventGridSubscription: 
      <function AzureRMEventGridSubscription.delete_subscription>

@hynek
Copy link

hynek commented Aug 2, 2022

I have run into the same problem while trying to debug build backends and I suspect we have the same problem: q respects tempfile.gettmpdir() which for instance in the project I'm working on looks like this:

>>> import tempfile; tempfile.gettempdir()
'/var/folders/7f/5bq0ctcs4tl_7k2721s0ycy80000gn/T'

It would be nice if I could overwrite that with something like Q_FORCE_FILE=/tmp/q.

@rouilj
Copy link

rouilj commented Nov 2, 2023

It would be nice if I could overwrite that with something like Q_FORCE_FILE=/tmp/q.

Did you try explicitly setting TMPDIR? Maybe the code that uses that does the right thing?

@jpmat296
Copy link

I confirm explicit setting of TMPDIR works well. On my computer with macOS 13.6, I had just to execute :

export TMPDIR=/tmp

And now I have q() output in /tmp/q

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants