Reply
Thread Tools
Posts: 1,548 | Thanked: 7,510 times | Joined on Apr 2010 @ Czech Republic
#1
Hello, I would like to ask, how Internet connectivity works on the N900 for python applications.
My application uses Internet for downloading files (OSM tiles, using the urllib.urlretrieve function) and everything works when running in Scratchbox. But on the N900, users report download errors, even though other applications (web browser, etc.) can use the Internet just fine.

So I would like to ask:
* Do I need to "enable" Internet connectivity for the application ?
* How can i do that, for a Python program ?

Thanks in advance !

Martin
 
Posts: 547 | Thanked: 1,383 times | Joined on Sep 2009 @ Stockholm, Sweden
#2
What kind of errors are they reporting? For me, if there is an active internet connection up the urllib function just works :-) OTOH you might have to get the proxy settings from ICD if the internet connection requires the user to use a proxy.

python-conic and/or some gconf magic should solve this, IAP information is stored in gconf at /system/osso/connectivity/IAP/
__________________

Problem with fMMS? Run in x-terminal: cp /tmp/fmms.log /home/user/MyDocs/
After that you'll see fmms.log in filemanager or when you connect the device to your desktop as a mass storage device.
E-mail the log to me, if you don't have the email address, drop me a PM. Thanks!

fMMS - MMS for your N900
fAPN - GUI for adding a new GPRS APN
If you like this post, don't be shy to thank me -->
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#3
as far as i am aware it depends on how the device configures.
Healthcheck needs internet activity for very little, but when it does, it either:
  • Asks the user for mermission, and to select a connection
  • Uses the current available connection
  • Will error out (in my case provide a blank number) if fails.
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Posts: 79 | Thanked: 20 times | Joined on Apr 2010
#4
My N900 Python app is successfully retrieving several small xml files and large (100+ MB) media files with the following:

req = urllib2.Request(url)
reply = urllib2.urlopen(req)

... then reading from reply. Without special configuration, although I am not behind a firewall.
 
Posts: 324 | Thanked: 371 times | Joined on Dec 2009 @ Vancouver, BC
#5
I use the following in FeedingIt, which seems to handle proxies pretty well.

Code:
def getProxy():
    import gconf
    if gconf.client_get_default().get_bool('/system/http_proxy/use_http_proxy'):
        port = gconf.client_get_default().get_int('/system/http_proxy/port')
        http = gconf.client_get_default().get_string('/system/http_proxy/host')
        proxy = proxy = urllib2.ProxyHandler( {"http":"http://%s:%s/"% (http,port)} )
        return (True, proxy)
    return (False, None)

# Enable proxy support
(proxy_support, proxy) = getProxy()
if proxy_support:
    opener = urllib2.build_opener(proxy)
    urllib2.install_opener(opener)

### Use urllib2.urlopen("http://...")
f = urllib2.urlopen("http://www.google.com")
data = f.read()
f.close()
 

The Following User Says Thank You to Slocan For This Useful Post:
Posts: 1,548 | Thanked: 7,510 times | Joined on Apr 2010 @ Czech Republic
#6
Thanks for your feedback !

I have created a simple script, that tests downloading files from the Internet to /tmp:
* using urlib <- this is what my app is currently using
* using urlib2
* setting up the proxy and then downloading files (thanks, Slocan !)
When I have results from N900 users (I dont have a N900 myself, yet , Ill sure let you know

..or, If someone is brave enought to test this, the testing script is here:
test_internet_connectivity.py
 
Posts: 324 | Thanked: 371 times | Joined on Dec 2009 @ Vancouver, BC
#7
As an update to my previous post, one user has reported that the proxy use doesn't work with his 3G connection. For some reason, /system/http_proxy/use_http_proxy is set to True, yet it needs to connect directly to get data. Maybe someone more familiar with these type of connections can enlighten us why it'd do that.
 
Posts: 1,548 | Thanked: 7,510 times | Joined on Apr 2010 @ Czech Republic
#8
In a surprising turn of events, the users, who previously reported errors, say its now working without problems...

Because I have done no modification to the downloading code, their internet connectivity was either misconfigured or there were some other external factors.

Conclusion: It is really not needed to ask for Internet connectivity on the N900, if there is already an active Internet connection.

So anyway, thanks for feedback, everybody !
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#9
Originally Posted by MartinK View Post
In a surprising turn of events, the users, who previously reported errors, say its now working without problems...

Because I have done no modification to the downloading code, their internet connectivity was either misconfigured or there were some other external factors.

Conclusion: It is really not needed to ask for Internet connectivity on the N900, if there is already an active Internet connection.

So anyway, thanks for feedback, everybody !
Which goes to show that 95% of all trouble reports are a case of "Problem Located Between Chair And Keyboard"...
 
Reply


 
Forum Jump


All times are GMT. The time now is 15:17.