472,954 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

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 5973
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
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
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
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
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.