From a1d63fd54d966d21087d57392987fa18c74896af Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 27 Jun 2013 12:09:41 -0400 Subject: [PATCH] api: Fix using staging.humbughq.com as the base_url. urlparse.urljoin(base_url, url) will drop any path inside base_url if either the url has a leading "/" or base_url doesn't have a trailing "/". So adjust our API bindings to ensure that doesn't happen. (imported from commit c080ee8c04b89127888609da28afc8b388af1911) --- humbug/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/humbug/__init__.py b/humbug/__init__.py index aa0a705..7c2f5b7 100644 --- a/humbug/__init__.py +++ b/humbug/__init__.py @@ -41,7 +41,7 @@ assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1')) # In newer versions, the 'json' attribute is a function, not a property requests_json_is_function = callable(requests.Response.json) -API_VERSTRING = "/v1/" +API_VERSTRING = "v1/" def generate_option_group(parser): group = optparse.OptionGroup(parser, 'API configuration') @@ -97,6 +97,8 @@ class Client(object): self.base_url = "https://api.humbughq.com" if self.base_url != "https://api.humbughq.com" and not self.base_url.endswith("/api"): self.base_url += "/api" + if not self.base_url.endswith("/"): + self.base_url += "/" self.retry_on_errors = retry_on_errors self.client_name = client @@ -122,7 +124,7 @@ class Client(object): if self.verbose: if not query_state["had_error_retry"]: sys.stdout.write("humbug API(%s): connection error%s -- retrying." % \ - (url.split(API_VERSTRING, 2)[1], error_string,)) + (url.split(API_VERSTRING, 2)[0], error_string,)) query_state["had_error_retry"] = True else: sys.stdout.write(".")