Debugging Python Tip

It’s not be something that too many people here will ever need to do, but nonetheless…

When Panorama runs a Python script, it creates a temporary Python file. The name begins with pan. plus the date in a dot format: 2023.10.23, plus the time in a dot format that is hard to precisely target and finally ends with .py. The name ends up something like this: pan.2023.10.12.12.19.42.650.py.

That python file is saved inside a folder nested within /private/var/folders/xxxx/T. The xxxx represents some folders that change from time to time but there are few of them so it’s not hard to find the T folder.

If the script runs successfully the file is immediately deleted. But if there’s an error the file remains behind, and that is the point of all of this.

The Python file can be opened in BBEdit and you can look at any problem line noted by Panorama’s error message or any other lines to see if there’s an obvious issue. You can try various solutions to debug it and have BBEdit run the script for you via Run/R in the #! menu. BBEdit creates a detailed Unix Script Output Log that shows the result.

Sometimes it turns out to be easy to recognize or find and correct the issue. But this method certainly beats trying to run it over and over in Panorama when trying to fix a Python issue.

1 Like

Could this be the one you are looking for?

Yes, it is - on your computer. On each of mine the path is different.

On this one it’s: /private/var/folders/xh/9tvzfycn1nz73cttxp425r_00000gn/T/

But the formula you’ve presented does correctly locate it. So thanks for adding that shortcut versus educated searching.

Actually,

info("tempfolder")

and

"/private"+info("tempfolder")

are exactly the same place! In other words, “/private”+ is not needed.

This temporary folder is a feature of macOS that Panorama makes available to Panorama developers and also uses itself. Here is a pretty good article about this folder and how to access it from the terminal:

Files and folders placed into this folder are eventually automatically deleted by macOS. So it’s a handy place for applications to put items that they need for a short time, but not permanently.