url lib

CSUIDL PROGRAMMEr amjadcsu at gmail.com
Fri Mar 20 13:07:15 EDT 2009


Hello
I am a novice python progammer

I am just writing a script that will automatically write my /etc/
yum.repos.d/* files in linux.

the problem is i am trying to connect to a secure repo and pass
username and password to the baseurl .

here is the baseurl
baseurl=http://USERNAME:PASSWORD@ydl.net/yum/6.1/../../../.

I have tried using the urllib2 in python

the code i tried was
req=urllib2.Request("http://USERNAME:PASSWord@ydl.net/cell/yum/6.1/
base)
try: urllib2.urlopen(req)
except urllib2.URLError,e:

Where Username:PASSWORD are speciefied by user

The Error i got was
File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
    return _opener.open(url, data)
  File "/usr/lib/python2.4/urllib2.py", line 358, in open
    response = self._open(req, data)
  File "/usr/lib/python2.4/urllib2.py", line 376, in _open
    '_open', req)
  File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.4/urllib2.py", line 1021, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.4/urllib2.py", line 980, in do_open
    h = http_class(host) # will parse host:port
  File "/usr/lib/python2.4/httplib.py", line 592, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.4/httplib.py", line 604, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: 'PAssword at ydl.net'

How can i connect to the site with password?? Do i have to implement
the ssl certification??



More information about the Python-list mailing list