BackupGGCode / python-for-android

Py4A
Apache License 2.0
0 stars 1 forks source link

BaseHTTPServer 'TCPServer' AttributeError #75

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Start any Python Script that contains "import BaseHTTPServer" on Android 
4.1.1.

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

I would expect the webserver to start ;) What I get instead is:
File 
"/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/
lib/python2.6/BaseHTTPServer.py", line 102, in <module>
AttributeError: 'module' object has no attribute 'TCPServer'

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

SL4A from sl4a_r6.apk
Python for Android from PythonForAndroid_r5.apk
On installation, the latter downloaded and extracted:
python_extras_r14.zip
python_r16.zip
python_scripts_r13.zip

The O/S is Android 4.1.1 on an Asus Transformer Prime TF201

Please provide any additional information below.

What's really odd is that the exact thing works fine on Android 2.2, and 
Android 4.1.2

The script I am trying is a dead standard example as follows:

import BaseHTTPServer, android
from os import path 

droid = android.Android() 
FILENAME = "/storage/sdcard0/www/pic.jpg" 
PORT = 9090

class Handler(BaseHTTPServer.BaseHTTPRequestHandler): 
    def do_GET(s): 
        """Respond to a GET request.""" 
        droid.cameraCapturePicture(FILENAME) 
        picture = open(FILENAME, 'rb')            
        s.send_response(200) 
        s.send_header("Content-Type", "image/jpeg") 
        s.end_headers() 
        s.wfile.write(picture.read()) 

server_class = BaseHTTPServer.HTTPServer 
httpd = server_class(('', PORT), Handler) 
httpd.serve_forever()

Original issue reported on code.google.com by stefan.s...@gmail.com on 25 Apr 2013 at 9:07

GoogleCodeExporter commented 9 years ago
I forgot to add : If I start a Python Interpreter and then type "import 
BaseHTTPServer" it accepts it just fine! It's just when it's inside a script :(

Original comment by stefan.s...@gmail.com on 25 Apr 2013 at 9:09