| Reply | « Previous Thread | Next Thread » |
|
How do people here debug stand-alone apps? I have an app that is a whole tree of files, so running it as a script is out. I build and run it as a sis, but when it dies I don't get to see the stack trace. Is there some trick to turn on the ability to see errors from the python interpreter?
-Seth |
|
To mimick a stack trace of the Python Script Shell, enclose your stand-alone program in a construct similar to this:
Code:
# Exception harness for "Python for S60" stand-alone programs
try:
# Actual program is here.
1 / 0
except:
import sys
import traceback
import e32
import appuifw
appuifw.app.screen = "normal" # Restore screen to normal size.
appuifw.app.focus = None # Disable focus callback.
body = appuifw.Text()
appuifw.app.body = body # Create and use a text control.
exitlock = e32.Ao_lock()
def exithandler(): exitlock.signal()
appuifw.app.exit_key_handler = exithandler # Override softkey handler.
appuifw.app.menu = [(u"Exit", exithandler)] # Override application menu.
body.set(unicode("\n".join(traceback.format_exception(*sys.exc_info()))))
exitlock.wait() # Wait for exit key press.
appuifw.app.set_exit()
|
|
One option is to use file logger utility, see this post for details: http://discussion.forum.nokia.com/fo...57&postcount=3
|
| simo.salminen |
| View Public Profile |
| Find all posts by simo.salminen |
|
Join Date: Feb 2004
Posts: 155
Location: Budapest, Hungary, Europe
Offline
Forum Nokia Champion
|
|
I have a slightly different problem: my PyS60 stand-alone app doesn't start at all. The application was assembled using Ensymble and it contains Python scripts as well as embedded SIS files. I've just added logging support to it and I'm afraid it's just that that causes it to malfunction.
Since logging does not work I cannot debug it. Now how shall I interpret jethro.fn's sentence: "...enclose your stand-alone program in a construct similar to this"? What to enclose? My stand-alone app naturally contains a default.py file, but it contains other files, too. Again, what to enclose? And am I right when I assume that I'll be unable to see any output? In which application's context would it be displayed (mine is crashing)? Thanks, Tote |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
Technically you should put the exception harness around the code in your main .py file (the one that is used to create the sis file using Ensymble's py2sis) if you have just one such file. At least I think so...
And if you haven't already, see this article. It might help a bit. |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
|
Quote:
the method suggested by jethro.fn is a nice one and the best way which work for me is the exception harness method which is best ported in the wiki have a look at that Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Quote:
I'll rewrite it later, --jouni |
|
Join Date: Feb 2004
Posts: 155
Location: Budapest, Hungary, Europe
Offline
Forum Nokia Champion
|
|
Okay, I spotted it! I used multi-line comments (triple apostrophes/quotes) at the beginning of a function and that confused everything. After removing it (and only that part!) my program now works.
The thing is that I couldn't debug it at all in the traditional way: couldn't show a dialog, write anything to file, nothing. The biggest problem was that my program went crazy at the very beginning of the execution, I guess there must be a validator somewhere "who" decides if a Python script is syntactically correct or not. Mine wasn't. ![]() So everybody, please learn from my mistake! I would be happier if I hadn't wasted couple of hours struggling to find this pity error. Cheers, Tote |
|
Quote:
![]() Short version: - Install python 2.5 - Install pylint - Run pylint on command line to check your PyS60 script - Fix the errors and warnings, I mean really do it - Redefine rule set by first writing defaults on file and then editing that I'll write tutorial one of these days, but I'm using it and it works. Cheers, --jouni |
|
Join Date: Feb 2004
Posts: 155
Location: Budapest, Hungary, Europe
Offline
Forum Nokia Champion
|
|
|
Quote:
Btw, is the following URL for pylint correct: http://www.logilab.org/857 ? Tote |
|
Quote:
Good luck, --jouni |
|
I debug using appuifw.query.
sys.stderr=lambda x: appuifw.query(x, "query") |
|
I just checked in my serial logging tool, LogMan. Check it out from:
http://code.google.com/p/logman-for-symbian/ Announcement is here. LogMan is a logging service running on Symbian phone intended for debugging tasks. The service allows one to send messages through a USB serial connection to PC. Other serial connection methods should work also, but are not supported. Infrared(IrComm), for example. On Symbian simulator, the messages are also logged to %TEMP%\epocwind.out by using RDebug logger. Code:
How to use 'print' with LogMan. =============================== import sys, pylogman l = pylogman.LogMan() l.Connect() # Replace standard output with LogMan's write method. sys.stdout.write = l.write print "Hello!" # 'Hello' is sent to PC ![]()
Last edited by GameDude : 2008-05-13 at 09:45.
Reason: Added announcement link
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| How to debug console application with CW3.1 and 3rd edition ? | 3rdparty | Mobile Java Tools & SDKs | 0 | 2006-02-01 18:40 |
| set apps to be run background manually | Rx-lee | General Symbian C++ | 2 | 2004-09-14 09:58 |
| WAP upload / Content-Type header is lost at WAP gateway | rabai | Symbian Networking & Messaging | 2 | 2004-02-24 12:59 |
| using th debug monitor | evertse | General Symbian C++ | 0 | 2003-10-22 09:24 |
| WAP Push Support in Series 60 Devices | yorgens | General Browsing | 3 | 2003-06-11 09:20 |