Debugging external python script with pdb.

Posted on
Sat Jan 20, 2024 7:55 am
anitchalk offline
Posts: 21
Joined: Nov 29, 2019

Debugging external python script with pdb.

Hi, I'm working on an external python script that I call from a schedule (i.e. under actions where you select "Execute Script (Script and File Actions)" ). I "feel" like I was able to do this before the last time I sat down and dove into something new. But maybe I'm fooling myself. I know this works during plugin development, so maybe that's what I'm thinking of and conflating the two. I'm running the following from the cmd line:
Code: Select all
 /usr/local/bin/indigo-host -d 100 -x ./foo.py

100 appears to be for pdb when I run indigo-host --help:
Code: Select all
  -d {0,100,101,102,200}, --debug {0,100,101,102,200}
                        Debug mode: PDB: 100, PuDB: 101, PyCharm: 102, Debug shell: 200

I've added calls to indigo.debugger() in my script, but as far as I can tell, execution just halts there. I've verified this by adding logging before and after the call to indigo.debugger(). As if some window is opening somewhere where I can step into the debugger but I don't see it.
So when I hit ctrl-c in the terminal window where I'm running indigo-host, after it exits, I see the following in the indigo logs:
Code: Select all
   Error                           ElementNotFoundError -- could not find plugin com.perceptiveautomation.indigoplugin.scriptexecutor.external

So I guess first question is.... am I being dumb in thinking this should work at all?
And if this should be working, any ideas why it isn't and also is the above ElementNotFoundError related?

Posted on
Mon Jan 22, 2024 2:49 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Debugging external python script with pdb.

Unfortunately, I don't think debugging scripts will work because the the special environment we have to set it up in.

One thought, since you seem to be familiar with plugins, would be to put the logic of your script into a plugin just for testing purposes. Then you can use the debugger to debug the plugin.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jan 24, 2024 11:12 am
anitchalk offline
Posts: 21
Joined: Nov 29, 2019

Re: Debugging external python script with pdb.

ooh, genius idea. Didn't even occur to me. May as well set up a 'blank' plugin for all future testing of scripts!

Thanks

Posted on
Thu Feb 29, 2024 11:06 am
anitchalk offline
Posts: 21
Joined: Nov 29, 2019

Re: Debugging external python script with pdb.

I understand that it is recommended to place all external scripts in /Library/Application Support/Perceptive Automation/Scripts (as indicated here). But, I like to keep test and production in separate directories so I can quickly switch back to a working copy if I'm not finished with updates.

When I click on the "Choose..." script button in the Actions dialog (when Type = "Execute Script"), the file dialog box that comes up always defaults to the indigo Scripts directory vs where the current file is located. I might be missing something elsewhere, but it seems that if my script location isn't in the recommended Scripts directory I don't know which one I'm currently pointing to at first glance? Obviously I can go and pick the one I want, but would be nice to see what I'm looking at without having to re-pick every time to be sure.

Totally understand that if no file has been set before in the dialog, it should always default to /Library/Application Support/Perceptive Automation/Scripts ! But when it has been set would be nice to know what is actually running.

Posted on
Thu Feb 29, 2024 12:21 pm
anitchalk offline
Posts: 21
Joined: Nov 29, 2019

Re: Debugging external python script with pdb.

Also.. obviously goes without saying this isn't very important. I will likely make my environment better by symlinking from the default location to whatever version I want to run/test. But still seems useful for others that might be confused on what is or isn't running.

Posted on
Thu Feb 29, 2024 1:28 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Debugging external python script with pdb.

We'll look into this. I would expect it to open to the folder containing the existing script as well.

Image

Posted on
Thu Feb 29, 2024 2:14 pm
anitchalk offline
Posts: 21
Joined: Nov 29, 2019

Re: Debugging external python script with pdb.

If it matters, I'm on 2023.2.0 (client and server)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests

cron