Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
implement raise_for_status, #45
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygeo committed Oct 26, 2015
1 parent 4cac8b4 commit a5906bf
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions mapbox/services/upload.py
Expand Up @@ -34,7 +34,11 @@ def _get_credentials(self):
"""
uri = URITemplate('%s/{username}/credentials' % self.baseuri).expand(
username=self.username)
return self.session.get(uri)
res = self.session.get(uri)
res.raise_for_status()
# TODO if there is a perms error,
# massage exeption to alert user about upload:* scope tokens
return res

def stage(self, filepath, creds=None):
"""Stages the user's file on S3
Expand Down Expand Up @@ -84,7 +88,9 @@ def extract(self, stage_url, tileset, name=None):
uri = URITemplate('%s/{username}' % self.baseuri).expand(
username=self.username)

return self.session.post(uri, json=msg)
res = self.session.post(uri, json=msg)
res.raise_for_status()
return res

def list(self):
"""List of all uploads
Expand All @@ -94,7 +100,9 @@ def list(self):
"""
uri = URITemplate('%s/{username}' % self.baseuri).expand(
username=self.username)
return self.session.get(uri)
res = self.session.get(uri)
res.raise_for_status()
return res

def delete(self, upload):
"""Delete the specified upload
Expand All @@ -106,7 +114,9 @@ def delete(self, upload):

uri = URITemplate('%s/{username}/{upload_id}' % self.baseuri).expand(
username=self.username, upload_id=upload_id)
return self.session.delete(uri)
res = self.session.delete(uri)
res.raise_for_status()
return res

def status(self, upload):
"""Check status of upload
Expand All @@ -121,7 +131,9 @@ def status(self, upload):

uri = URITemplate('%s/{username}/{upload_id}' % self.baseuri).expand(
username=self.username, upload_id=upload_id)
return self.session.get(uri)
res = self.session.get(uri)
res.raise_for_status()
return res

def upload(self, filepath, tileset):
"""High level function to upload a local file to mapbox tileset
Expand Down

0 comments on commit a5906bf

Please sign in to comment.