You Are Here:

Community: Developer Discussion Boards

#1 Old Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-14, 15:15

Join Date: Mar 2004
Posts: 14
lancew
Offline
Registered User
Hi everyone,
I have been trying to use urllib and am encountering problems. I have tried uninstalling Python and reinstalling and still it fails.
Below is the code that fails, I have other actual useful code that I want to use this for, but to simplify fault-finding I wrote this short bit of code and it failed too.



import urllib
print "hello"
f = urllib.urlopen("http://www.python.org").read()
print f

----
The output and errors I see are below:


hello
Traceback (most recent call last):
File "ped.py", line 908, in run_click
File "E:\Python\Urllib.py.py", line 3, in ?
f = urllib.urlopen("http://www.python.org").read()
File "c:\resource\urllib.py", line 43, in urlopen
return _urlopener.open(url)
File "c:\resource\urllib.py", line 123, in open
return getattr(self, name)(url)
File "c:\resource\urllib.py", line 229, in open_http
h.endheaders()
File "c:\resource\httplib.py", line 454, in endheaders
self._send_output()
File "c:\resource\httplib.py", line 405, in _send_output
self.send(msg)
File "c:\resource\httplib.py", line 385, in send
self.connect()
File "c:\resource\httplib.py", line 355, in connect
socket.SOCK_STREAM):
File "c:\resource\socket.py", line 229, in getaddrinfo
r_host = gethostbyname(host)
IOError: [Errno socket error] (0, 'getaddrinfo failed')


---

Any assistance would be really appreciated.

Lance
Reply With Quote

#2 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-14, 22:35

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
Quote:
Originally Posted by lancew View Post
Traceback (most recent call last):
File "ped.py", line 908, in run_click
Try whether it runs outside Ped. I had a small script which failed inside Ped and spent the whole evening trying to debug a perfectly ok script - in vain, naturally

Summary:
save as a file and run it from PythonShell.

Cheers,

--jouni
Reply With Quote

#3 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-15, 06:00

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Hi lancew,

Nothing is wrong with your code

Jouni is right! There are instances when trying to run scripts on PED fails, especially with scripts related to Access points and Upload data scripts, it usually returns the error below.

Quote:
(0, 'getaddrinfo failed')
However the same script will run perfectly fine on the PythonScript Shell.

Best Regards,
Croozeus
Reply With Quote

#4 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-20, 11:57

Join Date: Mar 2004
Posts: 14
lancew
Offline
Registered User
Thanks for the re-assurance.
I tried it not using PED and it worked ok.

However... my original code that is talking to a web API (JSON) still dies.


I shall do appropriate screengrabs etc and post them here.
It works to my base url www.lancewicks.com but then it fails when reading into my NoseRub install. www.lancewicks.com/noserub/ and deeper.

Thanks for the input.

Lance
Reply With Quote

#5 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-20, 12:16

Join Date: Mar 2004
Posts: 14
lancew
Offline
Registered User
Hmmm.... interesting.
I just ran the code I posted and it ran okay.
I edited the URL to my API url and it worked ok.

I then added import JSON and tried to read "f" using Json and it died.
When it dies it brings up the slect AP dialog twice. It only does it once when it works. Weird.

No unable to run at all. I am rebooting my phone to see if that helps.

Lance
Reply With Quote

#6 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-23, 20:28

Join Date: Jan 2008
Posts: 22
hyon
Offline
Registered User
I have a similar problem, but with Ensymble. My code works fine in Python Script Shell, but when I package it into a sis file, it stops at the following line:

onlineFile = urllib.urlopen(URL + Filename")

It doesn't even try to connect to the web (there is an icon that shows up normally, when it tries to connect). Is there some extra procedure that I missed? I use Jurgen Scheible's default access point setter code. Maybe that's causing some trouble?

Any help is appreciated!

Best,
Hyon Lee
Reply With Quote

#7 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-23, 21:33

Join Date: Jan 2008
Posts: 22
hyon
Offline
Registered User
Just to add some details to my previous post:

I'm using a 3rd Ed machine (Nokia 5500) and using Ensymble v0.26.
The program closes when it gets to the aforementioned line of code.
Reply With Quote

#8 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-24, 05:22

Join Date: Feb 2008
Posts: 2,543
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Online
Forum Nokia Champion
Quote:
Originally Posted by hyon View Post
I have a similar problem, but with Ensymble. My code works fine in Python Script Shell, but when I package it into a sis file, it stops at the following line:

onlineFile = urllib.urlopen(URL + Filename")

It doesn't even try to connect to the web (there is an icon that shows up normally, when it tries to connect). Is there some extra procedure that I missed? I use Jurgen Scheible's default access point setter code. Maybe that's causing some trouble?
hi hyon
it will be better if you tell the dibo about the procedure you followed to make your sis file.


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#9 Old Smile Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-24, 05:34

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by hyon View Post

onlineFile = urllib.urlopen(URL + Filename")

You have a problem in the code.
For extracting data from HTML documents using urllib, it goes like this

For eg.
Code:
sock = urllib.urlopen("http://diveintopython.org/"
You might need to modify your code to

onlineFile = urllib.urlopen(URL + "Filename")

Or try having the whole string in one variable and then try like

Code:
URL= URL + "Filename"
onlineFile = urllib.urlopen(URL)
Hope that helps

Best Regards,
Croozeus
Reply With Quote

#10 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-28, 21:28

Join Date: Jan 2008
Posts: 22
hyon
Offline
Registered User
The following is a test script that I wrote solely to test the urllib.urlopen command in a sis file:

Code:
import appuifw
import urllib
import os
import e32

file = urllib.urlopen(u"http://www.mobilenin.com/pys60/resources/ex_upload_file_to_url.py")
fileContent = file.read()
file.close()

newFile = open(u"e:\\path.py", 'w')
newFile.write(fileContent)
newFile.close()
and the following is how I packaged it using Ensymble v0.27:

Code:
ensymble.py py2sis --autostart --runinstall downloadTest.py
Also, I used Symbian Open Signed to sign it.

Please tell me what I am doing wrong!

Thanks,
Hyon
Reply With Quote

#11 Old Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-29, 05:38

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
Quote:
Originally Posted by hyon View Post
and the following is how I packaged it using Ensymble v0.27:

Code:
ensymble.py py2sis --autostart --runinstall downloadTest.py
Also, I used Symbian Open Signed to sign it.

Please tell me what I am doing wrong!

Thanks,
Hyon
You have to specify the capabilities when creating the sis file with Ensymble. So it should be like:
Code:
ensymble.py py2sis  --caps=LocalServices+NetworkServices+ProtServ+ReadUserData+SwEvent+UserEnvironment+WriteUserData+ReadDeviceData+WriteDeviceData --autostart --runinstall downloadTest.py
Reply With Quote

#12 Old Talking Re: Issue with urllib on Nokia E90, Python 1.4.3 - 2008-05-29, 19:17

Join Date: Jan 2008
Posts: 22
hyon
Offline
Registered User
ah ha! it works now.

although, it is VERY redundant, since i specify those capabilities on symbian signed...

thank you all for your help!

Hyon
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
which phones for laptop dvdljns PC Suite API and PC Connectivity SDK 2 2006-02-14 13:58

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia