I have trouble running a Python script from Symbian C++ code. Could someone give me an example of this?
I have tried:
-using CSPyInterpreter, but the code does not compile/link correctly. I have added some headers to Symbian SDK's include from "C:\Symbian\7.0s\Series60_v20\python-port-s60\symbian_python\Include", but it doesn't seem to work. This lead to missing io.h, which doesn't seem to exist. I'm using MS VC++.
-using RApaLsSession::StartApp(const CApaCommandLine& aCommandLine), but I don't know what to use in CApaCommandLine::SetDocumentNameL(const TDesC& aDocName). This almost opens the Pyhton script; the title can be seen, but the application does not run. Maybe something to do with ViewUID's, but I haven't found that concept from the documentation.
If someone has done this, I'll appreciate the help.
-using CSPyInterpreter, but the code does not compile/link correctly. I have added some headers to Symbian SDK's include from "C:\Symbian\7.0s\Series60_v20\python-port-s60\symbian_python\Include", but it doesn't seem to work. This lead to missing io.h, which doesn't seem to exist. I'm using MS VC++.
This answer only considers the "CSPyInterpreter"-option:
1) In ".mmp"-file you have to have line:
LIBRARY python222.lib
2) Include:
#include "CSPyInterpreter.h"
3) Running a script (you might want to consider wrapping this e.g. with "CAsyncCallBack"):
It seems, that the CSPyInterpreter is not included in every version of Python for Series60 SDK. My problem is, that I have to use the Symbian 7.0 SDK (and therefore the Python SDK for that). The CSPyInterpreter seems to be included in the Python SDK for Symbian 8.0 (which is Python_1_0_for_Series60_SDK_2nd_ed_FP2).
My next question is, has anyone lauched Python code using Symbian 7.0 SDK? Adding just the CSPyInterpreter.h to the older environment does not work.
Here is how you can print out error messages from Python C API:
First, define following function:
int PythonOutput(const char *buf, int n)
{
HBufC* buf16 = HBufC::NewLC(n);
buf16->Des().Copy(TPtrC8((unsigned char*)buf, n));
RDebug::Print(_L("[PYTHON ERROR]: %S"), buf16);
CleanupStack::PopAndDestroy();
return n;
}
Then, after interpreter is started, do following:
CSPyInterpreter* it = CSPyInterpreter::NewInterpreterL();
CleanupStack::PushL(it);
it->iStdO = &PythonOutput;
Now you can use if (PyErr_Occurred()) { PyErr_Print(); } to find out about errors.
Last edited by simo.salminen; 2006-08-23 at 15:26.
hii,
I'm new to symbian environment....
I've a small problem here...
I'm writing an application which calls for some python functions...
My Symbian-Python directory is in C:\Symbian\8.0a\S60_2nd_FP2\python-port-s60
While my app is in
C:\Symbian\8.0a\S60_2nd_FP2\Series60Ex
So whn i include Symbian-Python as user include in da mmp file of my application, its taking da address as
..\MyApp\group\C:\Symbian\8.0a\S60_2nd_FP2\Series60Ex
I need some help in this regard...its really urgent...so plz reply if some1 can help me in dis regard....