diff options
Diffstat (limited to 'lorrycontroller/gitano.py')
-rw-r--r-- | lorrycontroller/gitano.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lorrycontroller/gitano.py b/lorrycontroller/gitano.py index 3e36b81..6625757 100644 --- a/lorrycontroller/gitano.py +++ b/lorrycontroller/gitano.py @@ -21,6 +21,7 @@ import urllib2 import urlparse import cliapp +import requests import lorrycontroller @@ -113,21 +114,16 @@ class GitanoCommand(object): logging.debug('url=%r', url) try: - request = urllib2.Request(url, None, {}) - logging.debug('request=%r', request.get_full_url()) if self.username and self.password: - password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() - password_mgr.add_password(None, url, self.username, self.password) - auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr) - opener = urllib2.build_opener(auth_handler) - response = opener.open(url) + response = requests.get(url, auth=(self.username, + self.password)) else: - response = urllib2.urlopen(request) - except urllib2.URLError as e: + response = requests.get(url) + except (requests.exceptions.RequestException) as e: raise GitanoCommandFailure( self.trovehost, ' '.join(gitano_args), str(e)) - - return response.read() + + return response.text class LocalTroveGitanoCommand(GitanoCommand): |