Fixing a bug wherein self.headers doesn't exist - reference headers arg instead

This commit is contained in:
Ryan McGrath 2009-07-29 12:54:33 -04:00
parent 91e03fe7ef
commit 0101d3b3e4
3 changed files with 8 additions and 8 deletions

View file

@ -63,8 +63,8 @@ class setup:
self.auth_manager.add_password(None, "http://twitter.com", self.username, self.password)
self.handler = urllib2.HTTPBasicAuthHandler(self.auth_manager)
self.opener = urllib2.build_opener(self.handler)
if self.headers is not None:
self.opener.addheaders = [('User-agent', self.headers)]
if headers is not None:
self.opener.addheaders = [('User-agent', headers)]
try:
test_verify = simplejson.load(self.opener.open("http://twitter.com/account/verify_credentials.json"))
self.authenticated = True

View file

@ -63,10 +63,10 @@ class setup:
self.auth_manager.add_password(None, "http://twitter.com", self.username, self.password)
self.handler = urllib2.HTTPBasicAuthHandler(self.auth_manager)
self.opener = urllib2.build_opener(self.handler)
if self.headers is not None:
self.opener.addheaders = [('User-agent', self.headers)]
if headers is not None:
self.opener.addheaders = [('User-agent', headers)]
try:
test_verify = simplejson.load(self.opener.open("http://twitter.com/account/verify_credentials.json"))
simplejson.load(self.opener.open("http://twitter.com/account/verify_credentials.json"))
self.authenticated = True
except HTTPError, e:
raise TangoError("Authentication failed with your provided credentials. Try again? (%s failure)" % `e.code`, e.code)

View file

@ -23,7 +23,7 @@ except ImportError:
try:
import json as simplejson
except:
raise Exception("Tango requires the simplejson library (or Python 2.6) to work. http://www.undefined.org/python/")
raise Exception("Tango requires a json library to work. http://www.undefined.org/python/")
try:
import oauth
@ -63,8 +63,8 @@ class setup:
self.auth_manager.add_password(None, "http://twitter.com", self.username, self.password)
self.handler = urllib.request.HTTPBasicAuthHandler(self.auth_manager)
self.opener = urllib.request.build_opener(self.handler)
if self.headers is not None:
self.opener.addheaders = [('User-agent', self.headers)]
if headers is not None:
self.opener.addheaders = [('User-agent', headers)]
try:
test_verify = simplejson.load(self.opener.open("http://twitter.com/account/verify_credentials.json"))
self.authenticated = True