9
9
#define PY_SSIZE_T_CLEAN
10
10
#include "Python.h"
11
11
#ifndef Py_PYTHON_H
12
- #error Python headers needed to compile C extensions, please install development version of Python.
12
+ #error Python headers needed to compile C extensions, please install development version of Python.
13
13
#endif
14
14
15
15
static PyObject * androidembed_log (PyObject * self , PyObject * args ) {
@@ -23,7 +23,7 @@ static PyObject *androidembed_log(PyObject *self, PyObject *args) {
23
23
24
24
static PyMethodDef AndroidEmbedMethods [] = {
25
25
{"log" , androidembed_log , METH_VARARGS ,
26
- "Log on android platform" },
26
+ "Log on android platform" },
27
27
{NULL , NULL , 0 , NULL }
28
28
};
29
29
@@ -35,7 +35,7 @@ int asset_extract(AAssetManager *am, char *src_file, char *dst_file) {
35
35
FILE * fhd = fopen (dst_file , "wb" );
36
36
if (fhd == NULL ) {
37
37
LOGW ("Unable to open descriptor for %s (errno=%d:%s)" ,
38
- dst_file , errno , strerror (errno ));
38
+ dst_file , errno , strerror (errno ));
39
39
return -1 ;
40
40
}
41
41
@@ -63,7 +63,7 @@ void android_main(struct android_app* state) {
63
63
LOGI ("Initialize Python for Android" );
64
64
//env_argument = getenv("ANDROID_ARGUMENT");
65
65
//setenv("ANDROID_APP_PATH", env_argument, 1);
66
- //setenv("PYTHONVERBOSE", "2", 1);
66
+ //setenv("PYTHONVERBOSE", "2", 1);
67
67
Py_SetProgramName ("python-android" );
68
68
Py_Initialize ();
69
69
//PySys_SetArgv(argc, argv);
@@ -138,20 +138,20 @@ void android_main(struct android_app* state) {
138
138
139
139
// test import site
140
140
PyRun_SimpleString (
141
- "import site; print site.getsitepackages()\n" \
142
- "print 'Android path', sys.path\n" \
143
- "print 'Android bootstrap done. __name__ is', __name__" );
141
+ "import site; print site.getsitepackages()\n" \
142
+ "print 'Android path', sys.path\n" \
143
+ "print 'Android bootstrap done. __name__ is', __name__" );
144
144
145
145
/* run it !
146
- */
146
+ */
147
147
LOGI ("Extract main.py from assets" );
148
148
char main_fn [512 ];
149
149
snprintf (main_fn , 512 , "%s/main.pyo" , state -> activity -> internalDataPath );
150
150
if (asset_extract (am , "main.pyo" , main_fn ) < 0 )
151
151
return ;
152
152
153
153
/* run python !
154
- */
154
+ */
155
155
LOGI ("Run main.py >>>" );
156
156
FILE * fhd = fopen (main_fn , "rb" );
157
157
if (fhd == NULL ) {
@@ -166,12 +166,12 @@ void android_main(struct android_app* state) {
166
166
LOGW ("An error occured." );
167
167
PyErr_Print (); /* This exits with the right code if SystemExit. */
168
168
if (Py_FlushLine ())
169
- PyErr_Clear ();
169
+ PyErr_Clear ();
170
170
}
171
171
172
172
/* close everything
173
- */
174
- Py_Finalize ();
173
+ */
174
+ Py_Finalize ();
175
175
176
176
LOGW ("Python for android ended." );
177
177
}
0 commit comments