Skip to content

datacenter.me() method fails due to trailing '/' #11

@rcj4747

Description

@rcj4747

2014-01-26T16:43:08.933902 GET https://us-west-1.api.joyentcloud.com/my/
{"code":"ResourceNotFound","message":"/my/ does not exist"}
Traceback (most recent call last):
File "./joyent.py", line 15, in
id = sdc.me()['id']
File "/home/rcj/devel/source/joyent/working/smartdc/datacenter.py", line 349, in me
j, _ = self.request('GET', '')
File "/home/rcj/devel/source/joyent/working/smartdc/datacenter.py", line 251, in request
resp.raise_for_status()
File "/usr/lib/python2.7/dist-packages/requests/models.py", line 683, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found

There should not be a trailing '/' for the me() function. A simple fix is to strip the trailing '/' when the path is empty in the request function like this:

--- datacenter.py 2014-01-26 16:42:40.223213133 -0600
+++ datacenter.py.mod 2014-01-26 16:33:48.815219105 -0600
@@ -225,7 +225,10 @@
:Returns: tuple of decoded response body & Response object
:raises: client (4xx) errors
"""

  •    full_path = self.url + path
    
  •    if (path == ''):
    
  •        full_path = self.url.rstrip('/')
    
  •    else:
    
  •        full_path = self.url + path
     request_headers = {}
     request_headers.update(self.default_headers)
     if headers:
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions