473,490 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

urllib2.urlopen(req) error........

Can anyone comment on why the code shown in the Python error is in
some way incorrect...or is there a problem with Python on my hoster's
site ??
The highlites don't seem to show here...but line #80 and line # 38 are
the first line offenders.

--> --> -->

HTTPError Python 2.2.2: /usr/bin/python
Fri Jun 4 13:58:00 2004

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

/home/euromill/public_html/scgi-bin/euro3.py
78 write_dig_err(ls)

79 x = x + 1

80 process_request(ls)

81

82

process_request = <function process_request>, ls =
['johnfdutchfrederic', ['77', '77', '77', '77', '77', '77', '77'],
'EuroMillions', '5', 'error']
/home/euromill/public_html/scgi-bin/euro3.py in
process_request(ls=['johnfdutchfrederic', ['77', '77', '77', '77',
'77', '77', '77'], 'EuroMillions', '5', 'error'])
36 req = urllib2.Request(url='http://www.euromillions.us/scgi-bin/euro8.py',
\

37 data = strdata)

38 f = urllib2.urlopen(req)

39 print "Content-type: text/html\n\n"

40 print f.read()

f undefined, global urllib2 = <module 'urllib2' from
'/usr/lib/python2.2/urllib2.pyc'>, urllib2.urlopen = <function
urlopen>, req = <urllib2.Request instance>
/usr/lib/python2.2/urllib2.py in urlopen(url=<urllib2.Request
instance>, data=None)
136 if _opener is None:

137 _opener = build_opener()

138 return _opener.open(url, data)

139

140 def install_opener(opener):

global _opener = <urllib2.OpenerDirector instance>, _opener.open =
<bound method OpenerDirector.open of <urllib2.OpenerDirector
instance>>, url = <urllib2.Request instance>, data = None
/usr/lib/python2.2/urllib2.py in open(self=<urllib2.OpenerDirector
instance>, fullurl=<urllib2.Request instance>, data=None)
320 type_ = req.get_type()

321 result = self._call_chain(self.handle_open, type_, type_
+ \

322 '_open', req)

323 if result:

324 return result

req = <urllib2.Request instance>
/usr/lib/python2.2/urllib2.py in
_call_chain(self=<urllib2.OpenerDirector instance>, chain={'do':
[<urllib2.HTTPHandler instance>, <urllib2.HTTPSHandler instance>],
'file': [<urllib2.FileHandler instance>], 'ftp': [<urllib2.FTPHandler
instance>], 'http': [<urllib2.HTTPHandler instance>], 'https':
[<urllib2.HTTPSHandler instance>], 'proxy': [<urllib2.ProxyHandler
instance>], 'unknown': [<urllib2.UnknownHandler instance>]},
kind='http', meth_name='http_open', *args=(<urllib2.Request
instance>,))
299 func = getattr(handler, meth_name)

300

301 result = func(*args)

302 if result is not None:

303 return result

result undefined, func = <bound method HTTPHandler.http_open of
<urllib2.HTTPHandler instance>>, args = (<urllib2.Request instance>,)
/usr/lib/python2.2/urllib2.py in http_open(self=<urllib2.HTTPHandler
instance>, req=<urllib2.Request instance>)
788

789 def http_open(self, req):

790 return self.do_open(httplib.HTTP, req)

791

792

self = <urllib2.HTTPHandler instance>, self.do_open = <bound method
HTTPHandler.do_open of <urllib2.HTTPHandler instance>>, global httplib
= <module 'httplib' from '/usr/lib/python2.2/httplib.pyc'>,
httplib.HTTP = <class httplib.HTTP>, req = <urllib2.Request instance>
/usr/lib/python2.2/urllib2.py in do_open(self=<urllib2.HTTPHandler
instance>, http_class=<class httplib.HTTP>, req=<urllib2.Request
instance>)
782 return addinfourl(fp, hdrs, req.get_full_url())

783 else:

784 return self.parent.error('http', req, fp, code, msg,
hdrs)

785

786

self = <urllib2.HTTPHandler instance>, self.parent =
<urllib2.OpenerDirector instance>, self.parent.error = <bound method
OpenerDirector.error of <urllib2.OpenerDirector instance>>, req =
<urllib2.Request instance>, fp = <open file '<socket>', mode 'rb'>,
code = 500, msg = 'Internal Server Error', hdrs = <httplib.HTTPMessage
instance>
/usr/lib/python2.2/urllib2.py in error(self=<urllib2.OpenerDirector
instance>, proto=500, *args=({301: [<urllib2.HTTPRedirectHandler
instance>], 302: [<urllib2.HTTPRedirectHandler instance>], 'default':
[<urllib2.HTTPDefaultErrorHandler instance>]}, 'default',
'http_error_default', <urllib2.Request instance>, <open file
'<socket>', mode 'rb'>, 500, 'Internal Server Error',
<httplib.HTTPMessage instance>))
346 if http_err:

347 args = (dict, 'default', 'http_error_default') +
orig_args

348 return self._call_chain(*args)

349

350 # XXX probably also want an abstract factory that knows things
like

self = <urllib2.OpenerDirector instance>, self._call_chain = <bound
method OpenerDirector._call_chain of <urllib2.OpenerDirector
instance>>, args = ({301: [<urllib2.HTTPRedirectHandler instance>],
302: [<urllib2.HTTPRedirectHandler instance>], 'default':
[<urllib2.HTTPDefaultErrorHandler instance>]}, 'default',
'http_error_default', <urllib2.Request instance>, <open file
'<socket>', mode 'rb'>, 500, 'Internal Server Error',
<httplib.HTTPMessage instance>)
/usr/lib/python2.2/urllib2.py in
_call_chain(self=<urllib2.OpenerDirector instance>, chain={301:
[<urllib2.HTTPRedirectHandler instance>], 302:
[<urllib2.HTTPRedirectHandler instance>], 'default':
[<urllib2.HTTPDefaultErrorHandler instance>]}, kind='default',
meth_name='http_error_default', *args=(<urllib2.Request instance>,
<open file '<socket>', mode 'rb'>, 500, 'Internal Server Error',
<httplib.HTTPMessage instance>))
299 func = getattr(handler, meth_name)

300

301 result = func(*args)

302 if result is not None:

303 return result

result undefined, func = <bound method
HTTPDefaultErrorHandler.http_error...lt of
<urllib2.HTTPDefaultErrorHandler instance>>, args = (<urllib2.Request
instance>, <open file '<socket>', mode 'rb'>, 500, 'Internal Server
Error', <httplib.HTTPMessage instance>)
/usr/lib/python2.2/urllib2.py in
http_error_default(self=<urllib2.HTTPDefaultErrorH andler instance>,
req=<urllib2.Request instance>, fp=<open file '<socket>', mode 'rb'>,
code=500, msg='Internal Server Error', hdrs=<httplib.HTTPMessage
instance>)
398 class HTTPDefaultErrorHandler(BaseHandler):

399 def http_error_default(self, req, fp, code, msg, hdrs):

400 raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)

401

402 class HTTPRedirectHandler(BaseHandler):

global HTTPError = <class urllib2.HTTPError>, req = <urllib2.Request
instance>, req.get_full_url = <bound method Request.get_full_url of
<urllib2.Request instance>>, code = 500, msg = 'Internal Server
Error', hdrs = <httplib.HTTPMessage instance>, fp = <open file
'<socket>', mode 'rb'>
HTTPError: HTTP Error 500: Internal Server Error
_HTTPError__super_init = <bound method HTTPError.__init__ of
<HTTPError a...92 whose fp = <open file '<socket>', mode 'rb'>>>
__del__ = <bound method HTTPError.__del__ of <HTTPError at...92
whose fp = <open file '<socket>', mode 'rb'>>>
__doc__ = 'Raised when HTTP error occurs, but also acts like
non-error return'
__getitem__ = <bound method HTTPError.__getitem__ of
<HTTPErro...92 whose fp = <open file '<socket>', mode 'rb'>>>
__init__ = <bound method HTTPError.__init__ of <HTTPError a...92
whose fp = <open file '<socket>', mode 'rb'>>>
__module__ = 'urllib2'
__repr__ = <bound method HTTPError.__repr__ of <HTTPError a...92
whose fp = <open file '<socket>', mode 'rb'>>>
__str__ = <bound method HTTPError.__str__ of <HTTPError at...92
whose fp = <open file '<socket>', mode 'rb'>>>
close = <bound method HTTPError.close of <HTTPError at 1...92
whose fp = <open file '<socket>', mode 'rb'>>>
code = 500
filename = 'http://www.euromillions.us/scgi-bin/euro7.py'
fileno = <built-in method fileno of file object>
fp = <open file '<socket>', mode 'rb'>
geturl = <bound method HTTPError.geturl of <HTTPError at ...92
whose fp = <open file '<socket>', mode 'rb'>>>
hdrs = <httplib.HTTPMessage instance>
headers = <httplib.HTTPMessage instance>
info = <bound method HTTPError.info of <HTTPError at 13...92
whose fp = <open file '<socket>', mode 'rb'>>>
msg = 'Internal Server Error'
read = <built-in method read of file object>
readline = <built-in method readline of file object>
readlines = <built-in method readlines of file object>
url = 'http://www.euromillions.us/scgi-bin/euro7.py'
Jul 18 '05 #1
2 6068
Jo**********@urmc.rochester.edu (John F Dutcher) writes:
Can anyone comment on why the code shown in the Python error is in
some way incorrect...or is there a problem with Python on my hoster's
site ??
The highlites don't seem to show here...but line #80 and line # 38 are
the first line offenders.
So (writing your post for you, here) you've written a CGI script in
Python. Your script uses urllib2 to POST some data to a server, and
you're including the tracback from cgitb.
36 req = urllib2.Request(url='http://www.euromillions.us/scgi-bin/euro8.py',\
37 data = strdata) [...] code = 500, msg = 'Internal Server Error', hdrs = <httplib.HTTPMessage
instance>

[...]

euromillions.us is trying to tell you that euromillions.us is broken
(see RFC 2616, section 10.5.1 '500 Internal Server Error'). Maybe you
tickled the bug in the software running on euromillons.us by POSTing
bad data?

The problem is highly unlikely to be the result of a bug in the Python
library.
John
Jul 18 '05 #2
I don't really think there's any Python bug...just thought my hoster's
implementation (it's new to them) might be flawed.
The dismay is that there are (9) scripts which dynamically create html
pages
which work flawlessly on Win XP where I develope them. As with another
similar site I did....every single script has to be tweaked before it
will run on Linux
servers with Linux Python. In the current case, as with 90% of the
others, it's always 'premature end of script headers' as the error.
While the 'printing' of
the 'Content type:....' statements are very much in place, with the
accompanying '\n\n' to generate a blank line....there is still an
unfortunate session of trial and error to get past this issue. The
offending script noted here fails as it does 'process_req(ls)' (ls
being a list of parameters for the script being loaded (read)).
I just thought something 'new' might be going on given the point of
failure.

jj*@pobox.com (John J. Lee) wrote in message news:<87************@pobox.com>...
Jo**********@urmc.rochester.edu (John F Dutcher) writes:
Can anyone comment on why the code shown in the Python error is in
some way incorrect...or is there a problem with Python on my hoster's
site ??
The highlites don't seem to show here...but line #80 and line # 38 are
the first line offenders.


So (writing your post for you, here) you've written a CGI script in
Python. Your script uses urllib2 to POST some data to a server, and
you're including the tracback from cgitb.
36 req = urllib2.Request(url='http://www.euromillions.us/scgi-bin/euro8.py',\
37 data = strdata)

[...]
code = 500, msg = 'Internal Server Error', hdrs = <httplib.HTTPMessage
instance>

[...]

euromillions.us is trying to tell you that euromillions.us is broken
(see RFC 2616, section 10.5.1 '500 Internal Server Error'). Maybe you
tickled the bug in the software running on euromillons.us by POSTing
bad data?

The problem is highly unlikely to be the result of a bug in the Python
library.
John

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4436
by: bmiras | last post by:
I've got a problem using urllib2 to get a web page. I'm going through a proxy using user/password authentification and i'm trying to get a page asking for a HTTP authentification. And I'm using...
1
3937
by: Matthew Wilson | last post by:
I am writing a script to check on my router's external IP address. My ISP refreshes my IP very often and I use dyndns for the hostname for my computer. My Netgear mr814 router has a webserver that...
0
4952
by: Matt | last post by:
I'm trying to get the HTML data off of a webpage. Let's say for the sake of argument it's the python homepage. I've googled around and found some examples that people said worked. Here's what...
3
2000
by: EP | last post by:
Hello patient and tolerant Pythonistas, Iterating through a long list of arbitrary (and possibly syntactically flawed) urls with a urllib2 pinging function I get a hang up. No exception is...
1
2366
by: joemynz | last post by:
Help please with a URLError. Invoking a url that works in Firefox and IE results in a "urlerror 7, no address ..." in python. I need to debug why. Traceback is below. There's a redirect when the...
3
10166
by: m.banaouas | last post by:
Hi all, I started to use urllib2 library and HTTPBasicAuthHandler class in order to authenticate with a http server (Zope in this case). I don't know why but it doesn't work, while authenticating...
1
5731
by: Alessandro Fachin | last post by:
I write this simply code that should give me the access to private page with htaccess using a proxy, i don't known because it's wrong... import urllib,urllib2 #input url...
1
4824
by: est | last post by:
A simple py script import urllib2 req=urllib2.Request("http://www.google.com") req.set_proxy("127.0.0.1:1","http") print urllib2.urlopen(req).read()
1
1962
by: Larry Hale | last post by:
Since it seems I have a "unique" problem, I wonder if anyone could point me in the general/right direction for tracking down the issue and resolving it myself. See my prior post @...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.