web2py on Android

174 views
Skip to first unread message

Fernando Pacheco

unread,
Jul 14, 2013, 4:16:09 AM7/14/13
to web...@googlegroups.com
I'm trying to run a minimal version of web2py (git version) on Android (Samsung Galaxy Tab 2 10 ") with kivy (as a service, latest python version 2.7) and / or from the launcher SL4A (pythn 2.6).

Everything works fine when I use GET, but when I submit a form (POST) I get the following error:


close failed in file object destructor:

IOError: [Errno 5] I/O error

The admin application also has this problem (password submit with the same error).

Full web2py version
(from git) has the same problem.

I have tried to
detect the source of error with no luck. Has anyone run applications -on Android- that contain forms (POST) successfully?.Any thoughts on this?.

Thank you very much. Greetings. Fernando.
127.0.0.1.2013-07-14.04-08-19.9a47a329-25ec-41c2-8c6d-e00d2ed94d33

Massimo Di Pierro

unread,
Jul 14, 2013, 6:11:22 AM7/14/13
to web...@googlegroups.com
Can you try wrap (in main.py)

parse_get_post_vars(request, environ)

in try: ...  except IOError: pass and see what happens.

Web2py copies the input stream into a temp file in order to be able to parse it but also pass a copy to the app. I suspect something happens to the original stream and it gets closed twice (not sure why, not by web2py, but by the wsgi adapter). If we isolate the problem we can find a work around.

xi...@gmx.net

unread,
Sep 13, 2013, 5:52:35 PM9/13/13
to web...@googlegroups.com
I am facing perhaps a similar issue when I try to get my web2py (Version 2.5.1-stable+timestamp.2013.06.06.15.39.19) application running on a tablet with Android 4.3 and sl4a (python 2.6). GETs seems to be okay but POSTs (e.g. login as user) result in tickets. As any attempt to login results in tickets and is unsuccessful finally the content of tickets is not displayed in the browser but I manged to extract the complain:

"(self=FieldStorage(None, None, ''))"
'read_lines_to_outerboundary'
'Python 2.6.2: /data/user/0/com.googlecode.pythonforandroid/files/python/bin/python (prefix: /data/user/0/com.googlecode.pythonforandroid/files/python)'
"<type 'exceptions.IOError'>"
'Tue Sep 10 08:25:09 2013'
'delim'
"''"
"FieldStorage(None, None, '')"
"'-----------------------------53628658412953322821182323057--'"
'True'
"'-----------------------------53628658412953322821182323057'"
'Traceback (most recent call last):
  File "/storage/emulated/legacy/sl4a/scripts/web2py/gluon/main.py", line 533, in wsgibase
    parse_get_post_vars(request, environ)
  File "/storage/emulated/legacy/sl4a/scripts/web2py/gluon/main.py", line 348, in parse_get_post_vars
    dpost = cgi.FieldStorage(fp=body, environ=environ, keep_blank_values=1)
  File "/storage/emulated/legacy/sl4a/scripts/web2py/cgi.py", line 508, in __init__
    self.read_multi(environ, keep_blank_values, strict_parsing)
  File "/storage/emulated/legacy/sl4a/scripts/web2py/cgi.py", line 632, in read_multi
    environ, keep_blank_values, strict_parsing)
  File "/storage/emulated/legacy/sl4a/scripts/web2py/cgi.py", line 510, in __init__
    self.read_single()
  File "/storage/emulated/legacy/sl4a/scripts/web2py/cgi.py", line 647, in read_single
    self.read_lines()
  File "/storage/emulated/legacy/sl4a/scripts/web2py/cgi.py", line 669, in read_lines
    self.read_lines_to_outerboundary()
  File "/storage/emulated/legacy/sl4a/scripts/web2py/cgi.py", line 698, in read_lines_to_outerboundary
    line = self.fp.readline(1<<16)
IOError: [Errno 2] No such file or directory

When I add some python code to the cgi module function ' read_lines_to_outerboundary' to inspect self.fp ...

       while 1:
            print 'DBG: fp -> %s' % str(self.fp)
            line = self.fp.readline(1<<16)
            if not line:
                self.done = -1
                break

 ... I get the following:

DBG: fp -> <open file '<fdopen>', mode 'w+b' at 0x40b41ed0>

Any help or hints how to track down the root cause of this issue are appreciated very much.

Regards,
Michael
Reply all
Reply to author
Forward
0 new messages