Python Script Error Message

Hello
I’m hoping someone can help and that I’m in the right place. The problem I have is running a program on Windows 10 called Raccoon and AutoDockTools (http://autodock.scripps.edu/resources/raccoon) Unfortunately their support forums are offline and they have no way to contact them. When setting a directory in the Raccoon GUI we receive a message stating that it isn’t accessible. Looking at the raccoon.py script I can see the (“The directory:\n%s\n is not accessible” % DirName) error message but don’t understand what is causing it from looking at the code to work backwards to troubleshoot. What is TheCheck referring to?

Any help will be really appreciated :slight_smile:

Posting a screen shot is no use to anyone who is reading this by email,
or is blind or visually impaired and reading it with screen reader
software. In the future, please, it is much more friendly to copy and
paste the relevant section of the code, possibly in a pastebin, or
give a direct URL to the raccoon.py source code.

When asking for free technical support, the people you ask shouldn’t
have to go to the website and download the script themselves in order to
see the relevant code wink

Unfortunately the raccoon script uses what has been rightly described as
“the most diabolical Python anti-pattern” (bare excepts). The first
instance of the code looks like this:

while not dir_accepted:
    DirName = askdirectory()
    if DirName:
        try:
            if os.path.exists(DirName):
                # [...redacted for brevity...]
            else:
                # [...redacted for brevity...]
            if dir_accepted:
                JobDirectory.set(DirName)
                JobDirectoryInfo.set(CheckDiskSpace(DirName))
                TheCheck()
                return
        except:
            tkMessageBox.showerror("Error!",
                ("The directory:\n%s\n is not accessible" % DirName))
            JobDirectory.set("")
            JobDirectoryInfo.set("")
            TheCheck()
            return

Because of the bare except, there is no way of knowing what causes the
error. It could be literally anything, including bugs in the raccoon
script, such as either of the redacted sections, the JobDirectory…
calls, or the call to TheCheck. But given that TheCheck
is apparently called successfully in the except block, with no further
exception, I doubt it is that. More likely there is some other issue.

What makes you think that the call to TheCheck is specifically relevant?

The function TheCheck is there in the source code, it does what looks
like some data validity checks to my inexpert eye, also it sets some
config data, sets some other data, and sets some GUI user interface
elements. In other words, the function name is grossly misleading, as it
does much more than just a single “the check”.

But as I said, it seems to me that TheCheck is probably not relevant,
since it (apparently?) is successfully called after the “not accessible”
error message is displayed.

At the beginning of the script is a line DEBUG = False. You can edit
that to True and the script will print some very anaemic debugging
information, but that’s better than nothing. You will also need to run
the script from a terminal or console window in order to see the printed
output. So try that first of all, and see whether that gives you a
better idea of what is failing.

(In particular, it will tell you whether TheCheck is called once, or
twice.)

If that doesn’t help much, try editing line 1132 (the bare except)
with this two line change:

# line 1132
except:
    tkMessageBox.showerror("Error!", ...

to this:

# assuming you are running Python 3 or better
except Exception as err:
    print(type(err), err)
    tkMessageBox.showerror("Error!", ...

Again, that will require you to run from a terminal so you can see the
printed output. This will show you what the actual error was, although
not where it occurs.

For that, you could try this more substantial edit at line 1132:

except Exception as err:
    import traceback
    traceback.print_tb(err.__traceback__)
    print(type(err), err)
    tkMessageBox.showerror("Error!", ...

Hope this helps, and feel free to post back with the exception info
if you need more help.

Hi Steven
Thank you for your detailed response. I didn’t realise about the screenshot and pasted what I thought was relevant, so I will know for next time.
I didn’t necessarily think TheCheck was specifically relevant but haven’t not really used Python code before I didn’t know what it referred to.
I’ll try the steps you mentioned and see what I can find out. Thank you again.