← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #268022]: How to enable full error traceback

 

Question #268022 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/268022

    Status: Open => Answered

RaiMan proposed the following answer:
the basic problem (not traceback info, only the line in the main script)
should be fixed in tomorrows build.

--- sys.excepthook = log_uncaught_exceptions
... does not work in the Jython interpreter mode, that is used when you run scripts with the SikuliX IDE (from GUI or command line)

If you want to use this, you have to run the script with Jython
directly.

example:

print "************** starting mainpy.sikuli"
import sys
from os.path import dirname
import traceback

def log_uncaught_exceptions(type, value, tb):
    print "*** exception_hook"
    for e in traceback.format_tb(tb): print e
    print "--- error"
    print str(value)

sys.excepthook = log_uncaught_exceptions

print "**** sys.argv"
for e in sys.argv: print e

print "*** sys.path"
dir = dirname(dirname(sys.argv[0]))
if not dir in sys.path: sys.path.append(dir)
for e in sys.path: print e

from subpy import *
func()

# content of subpy.py in same folder a s mainpy
print "import: subpy.py"
def func():
	1/0

--- a run command

java -Xmx512M -Dfile.encoding=UTF-8 -cp <path-to-sikulix.jar>
org.python.util.jython <path-to-someScript.sikuli/someScript.py>

one might also install Jython separately and use the jython.bat after
having prepared the environment accordingly.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.