khanwea / android-python27

Automatically exported from code.google.com/p/android-python27
0 stars 0 forks source link

Log traceback on broken hello.py #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Change hello.py to something "broken" (put some "import PLEASE_BREAK" 
anywhere)
2.The Python code crash
3.You cannot see the traceback

What is the expected output? What do you see instead?

To help debug hello.py, is useful to get the traceback provided by the Python 
interpreter, hopefully at the logcat. There is an logfile saved to the sdcard, 
but it does not contain stdout output, so its not useful.

What version of the product are you using? On what operating system?

Android 2.3.3, 4.0.5 and 4.1

Please provide any additional information below.

I managed to fix this, but had no time to create a proper pull-request yet, but 
I will. Mail me if you're in a hurry and we can talk.

Original issue reported on code.google.com by alan.jus...@gmail.com on 26 Jul 2013 at 7:14

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
typo: logfile does not logs "stderr" messages. "stderr" is where the traceback 
goes

Original comment by alan.jus...@gmail.com on 26 Jul 2013 at 7:16

GoogleCodeExporter commented 9 years ago
moderator: please change from "defect" to "feature"

Original comment by alan.jus...@gmail.com on 26 Jul 2013 at 7:25

GoogleCodeExporter commented 9 years ago

Original comment by anthony....@gmail.com on 29 Jul 2013 at 8:36

GoogleCodeExporter commented 9 years ago
Seems the log file is flushed only from time to time (maybe StreamGobbler 
issue: http://code.google.com/p/android-python27/issues/detail?id=5 ), in my 
code I do see log there but with delay.

However I'm not using the log created by StreamGobbler, instead I'm using the 
Python logging module and I redirect log entries into my own file.

As for the traceback I'm using the Python traceback module: 
traceback.extract_tb(...

You can also run your script from the cmd line to check what's going on:

export PYTHONHOME=/data/data/com.android.python27/files/python

export 
PYTHONPATH=/sdcard/com.android.python27/extras/python:/data/data/com.android.pyt
hon27/files/python/lib/python2.7/lib-dynload:/data/data/com.android.python27/fil
es/python/lib/python2.7

export PATH=$PYTHONHOME/bin:$PATH

export 
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/data/com.android.python27/files/python/li
b:/data/data/com.android.python27/files/python/lib/python2.7/lib-dynload

export AP_HOST=localhost

export AP_PORT=45777

am start -a com.android.python27.LAUNCH_RPC_SERVER -n 
com.android.python27/.RpcServerLauncher --ei 
com.android.python27.RPC_SERVER_PORT 45777

python my_script.py

Original comment by anthony....@gmail.com on 29 Jul 2013 at 8:45