Fix issues with trailing slashes in API examples URLs.
(imported from commit f557a65e36aefcdcd9e072e9144f3ec69f518192)
This commit is contained in:
parent
dde4b785f9
commit
ffd2f14df5
|
@ -3,6 +3,7 @@ import simplejson
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
import urlparse
|
||||||
|
|
||||||
# Check that we have a recent enough version
|
# Check that we have a recent enough version
|
||||||
assert(requests.__version__ > '0.12')
|
assert(requests.__version__ > '0.12')
|
||||||
|
@ -19,7 +20,7 @@ class HumbugAPI():
|
||||||
request["api-key"] = self.api_key
|
request["api-key"] = self.api_key
|
||||||
while True:
|
while True:
|
||||||
try:
|
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:
|
if res.status_code == requests.codes.service_unavailable:
|
||||||
# On 503 errors, try again after a short sleep
|
# On 503 errors, try again after a short sleep
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
|
@ -12,7 +12,7 @@ Example: send-message --user=tabbott@humbughq.com --site=http://127.0.0.1:8000
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option('--site',
|
parser.add_option('--site',
|
||||||
dest='site',
|
dest='site',
|
||||||
default="https://app.humbughq.com/",
|
default="https://app.humbughq.com",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option('--api-key',
|
parser.add_option('--api-key',
|
||||||
dest='api_key',
|
dest='api_key',
|
||||||
|
|
|
@ -12,7 +12,7 @@ Example: subscribe --user=tabbott@humbughq.com --site=http://127.0.0.1:8000
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option('--site',
|
parser.add_option('--site',
|
||||||
dest='site',
|
dest='site',
|
||||||
default="https://app.humbughq.com/",
|
default="https://app.humbughq.com",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option('--api-key',
|
parser.add_option('--api-key',
|
||||||
dest='api_key',
|
dest='api_key',
|
||||||
|
|
Loading…
Reference in a new issue