Permalink
Browse files

Add first version of config retrieval

  • Loading branch information...
1 parent 508b21f commit c2941165eff7a27586858c9ee6ee4811cc7ae67f @Almad Almad committed Nov 11, 2009
Showing with 28 additions and 0 deletions.
  1. +1 −0 cthylla/__init__.py
  2. +27 −0 cthylla/config.py
View
@@ -4,3 +4,4 @@
__version__ = VERSION
__versionstr__ = '.'.join(map(str, VERSION))
+from cthylla.config import get_buildmaster_config
View
@@ -0,0 +1,27 @@
+__all__ = ("get_buildmaster_config",)
+
+import logging
+import urllib2
+
+from pickle import loads
+
+REALM = "buildmaster"
+
+def get_buildmaster_config(uri, username, password):
+ auth_handler = urllib2.HTTPDigestAuthHandler()
+ auth_handler.add_password(REALM, uri, username, password)
+ opener = urllib2.build_opener(auth_handler)
+
+ request = urllib2.Request(uri)
+ try:
+ response = opener.open(request)
+ except urllib2.HTTPError, err:
+ if err.fp:
+ error = ": %s" % err.fp.read()
+ else:
+ error = ''
+ logging.error("Error occured while opening HTTP %s" % error)
+ raise
+ res = response.read()
+ response.close()
+ return loads(res)

0 comments on commit c294116

Please sign in to comment.