aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2010-10-29 20:39:20 +0000
committerRob Austein <sra@hactrn.net>2010-10-29 20:39:20 +0000
commit34e8dfc2b80bfe3ba1abcc94559982fa48fa852b (patch)
tree7b08d9f658d7a0d3bc1af9bc4c229b13e49279a8 /scripts
parentcfd95293ef22a70fcd199e8e3fba7ad8d51ff103 (diff)
Work around gratuitous 401 failure problem
svn path=/scripts/rpkidemo; revision=3514
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/rpkidemo36
1 files changed, 22 insertions, 14 deletions
diff --git a/scripts/rpkidemo b/scripts/rpkidemo
index 3f498430..ef13f805 100755
--- a/scripts/rpkidemo
+++ b/scripts/rpkidemo
@@ -141,6 +141,28 @@ class main(object):
os.environ["TZ"] = "UTC"
time.tzset()
+ def make_opener(self):
+ """
+ Avoid issue where the http password manager keeps track of how
+ many attempts are made. There's probably a better way to do this.
+ """
+
+ auth_handler = urllib2.HTTPDigestAuthHandler()
+ auth_handler.add_password(
+ realm = self.realm,
+ uri = self.base_url,
+ user = self.username,
+ passwd = self.password)
+
+ if self.use_cookies:
+ handlers = (auth_handler, urllib2.HTTPCookieProcessor())
+ else:
+ handlers = (auth_handler,)
+
+ return urllib2.build_opener(*handlers)
+
+ opener = property(make_opener)
+
def setup_username(self):
"""
Get username and password for web interface, construct urllib2
@@ -156,20 +178,6 @@ class main(object):
self.username = raw_input("Username: ")
self.password = getpass.getpass()
- auth_handler = urllib2.HTTPDigestAuthHandler()
- auth_handler.add_password(
- realm = self.realm,
- uri = self.base_url,
- user = self.username,
- passwd = self.password)
-
- if self.use_cookies:
- handlers = (auth_handler, urllib2.HTTPCookieProcessor())
- else:
- handlers = (auth_handler,)
-
- self.opener = urllib2.build_opener(*handlers)
-
self.opener.open(self.base_url) # Test login credentials
return