![]() |
| ||||||||||||||||||
![]() |
| ||||||||||||||||||
|
Programs contain errors, the same is true for plugins. There are two types of errors in Python plugins:
c:\MyPythonInstallationPath\python.exe MyPlugin.py This will show you a traceback. After correcting the error you have to restart YASARA.
If you want to print debug statements to trace a problem,
this is easily done using
print "MyMessage"in Yanaconda and yasara.write(WhatEver)in Python plugins. 'WhatEver' does not have to be a string, but just anything you can pass to Python's print function. DO NOT use Python's print function directly, because this fails under Windows unless you also flush the output buffer with sys.stdout.flush() If your Python plugin hangs in an infinite loop, click on Options
> Stop plugin. This will terminate your plugin as soon as it tries to print something or calls a YASARA command. If the plugin does not do any of these things,
YASARA will also hang until you kill the Python task manually from the Windows Task Manager,
with the Linux 'kill' command or with the MacOSX 'Activity Monitor' (can be found in the Applications/Utilities folder).
If you add an extra user interface to your plugin using the Tkinter framework
, you may encounter the problem that fatal errors occurring in your plugin are not reported by YASARA immediately. The reason is that Tkinter does not terminate after an error,
and also does not flush the output buffer properly, so that error messages get stuck and reach YASARA only when your plugin truly exits. The solution is to force Tkinter to exit when an error occurs:
class CallWrapper:
def __init__(self, func, subst, widget):
self.func = func
self.subst = subst
self.widget = widget
def __call__(self, *args):
try:
if self.subst:
args = self.subst(*args)
return self.func(*args)
except SystemExit, msg:
raise SystemExit, msg
except:
self.widget._report_exception()
raise SystemExit <<<< Newly added!
| ||||||||||||||||||