How to debug the passing of source and destination paths to Python script?

I'm a heavy user of Python scripts for admin tasks. I don't normally have a problem using these with Directory Opus, but today I wanted to direct the output of a Python script that takes a problematic zip file and extracts its contents to the destination directory.

It is failing, and I can't see why, even though the same script works fine from the command line. It therefore seems to be something about the way I have set up the custom button.

"C:\Program Files\Python312\python.exe" "D:\W\30-39 Tools\32 Code projects\sjisunzip_python\sjisunzip.py" {filepath} {destpath}

I have also tried things like:
@set dest={destpath|Select destination folder}
@output
"C:\Program Files\Python312\python.exe" "D:\W\30-39 Tools\32 Code projects\sjisunzip_python\sjisunzip.py" "{filepath}" "{$dest}"

...but I'm being hampered by my lack of experience with such commands. Also, at best I get a brief flash of the command line output before the window disappears.

Is there something obvious I should look at? In general terms, how should I approach debugging this sort of issue? Can I generate a message box or perform logging from within Dopus?

Thank you,
Dan
EDIT This is in 13.14, even though my profile strangely shows v9!

Yes.

1 Like

Thank you. With the output from "Run with logging" I was able to establish that the final pair of quotation marks was causing a problem.

@set dest={destpath|Select destination folder}
@output
"C:\Program Files\Python312\python.exe" "D:\W\30-39 Tools\32 Code projects\sjisunzip_python\sjisunzip.py" "{filepath}" {$dest}

I also found that there was also an issue with the trailing backslash, which I had to allow for in the Python script.

It works now. Still wondering whether is a simpler way to approach such tasks but at least I have something that functions.

Dan

{filepath} and similar codes will have quotes added automatically, if the thing they’re inserting contains a space.

It's smart enough that "{filepath}" won't give you extra quotes, but also a good idea to make it explicit with @nofilenamequoting, like this (assuming you want quotes around both):

@nofilenamequoting
"C:\Program Files\Python312\python.exe" "D:\W\30-39 Tools\32 Code projects\sjisunzip_python\sjisunzip.py" "{filepath$}" "{destpath$}"

I'm also using the $ versions of both {...} codes, to prevent the button running at all if those details are missing.

If it's causing problems, you can also suppress the backslash at the end of folder paths using noterm, like this:

@nofilenamequoting
"C:\Program Files\Python312\python.exe" "D:\W\30-39 Tools\32 Code projects\sjisunzip_python\sjisunzip.py" "{filepath$|noterm}" "{destpath$|noterm}"
1 Like

Thank you for that Leo, it was informative and a useful reminder of the breadth of Dopus' capabilities.

A few weeks ago I was in the attic and came across my original Amiga Directory Opus manual and discs, so my relationship with the software stretches back more than thirty years.

Despite that my daily use tends to be fairly pedestrian - lots of file copying and folder creation, custom buttons, renaming, that sort of thing. I should probably spend a bit of time exploring these features.

Regards,
Dan

1 Like