Fix issues with trailing slashes in API examples URLs.

(imported from commit f557a65e36aefcdcd9e072e9144f3ec69f518192)
This commit is contained in:
Tim Abbott 2012-10-18 11:32:58 -04:00
parent dde4b785f9
commit ffd2f14df5
3 changed files with 4 additions and 3 deletions

View file

@ -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)

View file

@ -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',

View file

@ -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',