Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record date #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/kegbot/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
1,129 changes: 748 additions & 381 deletions python/kegbot/api/api_pb2.py

Large diffs are not rendered by default.

70 changes: 43 additions & 27 deletions python/kegbot/api/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,62 @@
class Error(Exception):
"""An error occurred."""
HTTP_CODE = 400
def __init__(self, message=None):
self.message = message

def Message(self):
if self.message:
return self.message
m = self.__class__.__doc__
m = m.split('\n', 1)[0]
return m
"""An error occurred."""

HTTP_CODE = 400

def __init__(self, message=None):
self.message = message

def Message(self):
if self.message:
return self.message
m = self.__class__.__doc__
m = m.split("\n", 1)[0]
return m


class NotFoundError(Error):
"""The requested object could not be found."""
HTTP_CODE = 404
"""The requested object could not be found."""

HTTP_CODE = 404


class RequestError(Error):
"""There was an error fufilling the request."""
"""There was an error fufilling the request."""


class ServerError(Error):
"""The server had a problem fulfilling your request."""
HTTP_CODE = 500
"""The server had a problem fulfilling your request."""

HTTP_CODE = 500


class BadRequestError(Error):
"""The request was incomplete or malformed."""
HTTP_CODE = 400
"""The request was incomplete or malformed."""

HTTP_CODE = 400


class NoAuthTokenError(Error):
"""An api_key is required."""
HTTP_CODE = 401
"""An api_key is required."""

HTTP_CODE = 401


class BadApiKeyError(Error):
"""The api_key given is invalid."""
HTTP_CODE = 401
"""The api_key given is invalid."""

HTTP_CODE = 401


class PermissionDeniedError(Error):
"""The api_key given does not have permission for this resource."""
HTTP_CODE = 401
"""The api_key given does not have permission for this resource."""

HTTP_CODE = 401


MAP_NAME_TO_EXCEPTION = dict((c.__name__, c) for c in Error.__subclasses__())

def ErrorCodeToException(code, message=ServerError):
cls = MAP_NAME_TO_EXCEPTION.get(code, Error)
return cls(message)

def ErrorCodeToException(code, message=ServerError):
cls = MAP_NAME_TO_EXCEPTION.get(code, Error)
return cls(message)
Loading