| Reply | « Previous Thread | Next Thread » |
|
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 |
|
Quote:
![]() Summary: save as a file and run it from PythonShell. Cheers, --jouni |
|
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:
Best Regards, Croozeus |
|
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 |
|
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 |
|
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 |
|
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. |
|
Join Date: Feb 2008
Posts: 2,543
Location: Bhavnagar, Gujarat, India
gaba88
Online
Forum Nokia Champion
|
|
|
Quote:
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 |
|
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/"
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) Best Regards, Croozeus |
|
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() Code:
ensymble.py py2sis --autostart --runinstall downloadTest.py Please tell me what I am doing wrong! Thanks, Hyon |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
|
Quote:
Code:
ensymble.py py2sis --caps=LocalServices+NetworkServices+ProtServ+ReadUserData+SwEvent+UserEnvironment+WriteUserData+ReadDeviceData+WriteDeviceData --autostart --runinstall downloadTest.py |
|
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| 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 |