From ffd2f14df548202ed0b0c8d931a51e0a51c04359 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 18 Oct 2012 11:32:58 -0400 Subject: [PATCH] Fix issues with trailing slashes in API examples URLs. (imported from commit f557a65e36aefcdcd9e072e9144f3ec69f518192) --- common.py | 3 ++- examples/send-message | 2 +- examples/subscribe | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common.py b/common.py index 2b11521..b12baf2 100644 --- a/common.py +++ b/common.py @@ -3,6 +3,7 @@ import simplejson import requests import time import traceback +import urlparse # Check that we have a recent enough version assert(requests.__version__ > '0.12') @@ -19,7 +20,7 @@ class HumbugAPI(): request["api-key"] = self.api_key while True: try: - res = requests.post(self.base_url + url, data=request, verify=True) + res = requests.post(urlparse.urljoin(self.base_url, url), data=request, verify=True) if res.status_code == requests.codes.service_unavailable: # On 503 errors, try again after a short sleep time.sleep(0.5) diff --git a/examples/send-message b/examples/send-message index 003b914..e220a65 100755 --- a/examples/send-message +++ b/examples/send-message @@ -12,7 +12,7 @@ Example: send-message --user=tabbott@humbughq.com --site=http://127.0.0.1:8000 parser = optparse.OptionParser(usage=usage) parser.add_option('--site', dest='site', - default="https://app.humbughq.com/", + default="https://app.humbughq.com", action='store') parser.add_option('--api-key', dest='api_key', diff --git a/examples/subscribe b/examples/subscribe index 0615fcd..05f588d 100755 --- a/examples/subscribe +++ b/examples/subscribe @@ -12,7 +12,7 @@ Example: subscribe --user=tabbott@humbughq.com --site=http://127.0.0.1:8000 parser = optparse.OptionParser(usage=usage) parser.add_option('--site', dest='site', - default="https://app.humbughq.com/", + default="https://app.humbughq.com", action='store') parser.add_option('--api-key', dest='api_key',