rbx 3.19.2.dev172__tar.gz → 3.20.0.dev175__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/PKG-INFO +1 -1
  2. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/pyproject.toml +2 -2
  3. rbx-3.20.0.dev175/rbx/__init__.py +1 -0
  4. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/clients/__init__.py +10 -3
  5. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/clients/retry.py +6 -2
  6. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/exceptions.py +10 -4
  7. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/web/handlers.py +20 -1
  8. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx.egg-info/PKG-INFO +1 -1
  9. rbx-3.19.2.dev172/rbx/__init__.py +0 -1
  10. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/LICENSE +0 -0
  11. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/README.md +0 -0
  12. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/auth/__init__.py +0 -0
  13. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/auth/decorators.py +0 -0
  14. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/auth/id_token.py +0 -0
  15. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/auth/keystore.py +0 -0
  16. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/auth/mock.py +0 -0
  17. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/aws/__init__.py +0 -0
  18. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/aws/s3.py +0 -0
  19. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/buildtools/__init__.py +0 -0
  20. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/buildtools/cli.py +0 -0
  21. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/buildtools/tasks/__init__.py +0 -0
  22. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/buildtools/tasks/ec2.py +0 -0
  23. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/buildtools/tasks/image.py +0 -0
  24. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/buildtools/tasks/misc.py +0 -0
  25. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/clients/adsquare.py +0 -0
  26. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/clients/broadsign.py +0 -0
  27. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/clients/oxr.py +0 -0
  28. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/clients/panels.py +0 -0
  29. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/clients/reporting.py +0 -0
  30. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/gcp/__init__.py +0 -0
  31. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/gcp/cloud_tasks.py +0 -0
  32. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/gcp/pubsub.py +0 -0
  33. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/gcp/storage.py +0 -0
  34. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/logging.py +0 -0
  35. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/settings.py +0 -0
  36. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/utils/__init__.py +0 -0
  37. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/utils/mdm.py +0 -0
  38. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/utils/vast.py +0 -0
  39. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx/web/__init__.py +0 -0
  40. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx.egg-info/SOURCES.txt +0 -0
  41. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx.egg-info/dependency_links.txt +0 -0
  42. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx.egg-info/entry_points.txt +0 -0
  43. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx.egg-info/requires.txt +0 -0
  44. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/rbx.egg-info/top_level.txt +0 -0
  45. {rbx-3.19.2.dev172 → rbx-3.20.0.dev175}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rbx
3
- Version: 3.19.2.dev172
3
+ Version: 3.20.0.dev175
4
4
  Summary: A collection of common tools for Scoota services.
5
5
  Author-email: The Scoota Engineering Team <engineering@scoota.com>
6
6
  License:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rbx"
7
- version = "3.19.2.dev172"
7
+ version = "3.20.0.dev175"
8
8
  description = "A collection of common tools for Scoota services."
9
9
  authors = [
10
10
  { name = "The Scoota Engineering Team", email = "engineering@scoota.com" }
@@ -80,7 +80,7 @@ homepage = "https://github.com/rockabox/rbx"
80
80
  repository = "https://github.com/rockabox/rbx.git"
81
81
 
82
82
  [tool.bumpversion]
83
- current_version = "3.19.2.dev172"
83
+ current_version = "3.20.0.dev175"
84
84
  commit = true
85
85
  parse = """
86
86
  (?P<major>\\d+)\\.
@@ -0,0 +1 @@
1
+ __version__ = "3.20.0.dev175"
@@ -11,8 +11,9 @@ from requests.exceptions import ConnectionError, Timeout
11
11
  from ..exceptions import (
12
12
  ClientError,
13
13
  Forbidden,
14
+ RequestTimeout,
14
15
  ServerError,
15
- TransientServerError,
16
+ TooManyRequests,
16
17
  Unauthorized,
17
18
  )
18
19
  from ..utils import Singleton
@@ -174,7 +175,7 @@ class Client(metaclass=Singleton):
174
175
  else:
175
176
  response = getattr(requests, method)(url, **args)
176
177
  except (ConnectionError, Timeout) as e:
177
- raise TransientServerError(message=str(e), status_code=500, url=url)
178
+ raise RequestTimeout(message=str(e), url=url)
178
179
 
179
180
  # Never include the password field in the log on failure
180
181
  payload = copy(data)
@@ -182,7 +183,7 @@ class Client(metaclass=Singleton):
182
183
  payload.pop("password", None)
183
184
 
184
185
  if response.status_code == 500:
185
- raise TransientServerError(response.text, details=payload, url=url)
186
+ raise ServerError(response.text, details=payload, url=url)
186
187
 
187
188
  if response.status_code == 401:
188
189
  raise Unauthorized(self.get_message(response), details=payload, url=url)
@@ -190,6 +191,12 @@ class Client(metaclass=Singleton):
190
191
  if response.status_code == 403:
191
192
  raise Forbidden(self.get_message(response), details=payload, url=url)
192
193
 
194
+ if response.status_code == 408:
195
+ raise RequestTimeout(self.get_message(response), details=payload, url=url)
196
+
197
+ if response.status_code == 429:
198
+ raise TooManyRequests(self.get_message(response), details=payload, url=url)
199
+
193
200
  if response.status_code >= 400:
194
201
  raise ClientError(
195
202
  response.text,
@@ -49,12 +49,16 @@ def if_exception_type(*exception_types):
49
49
  """A predicate that checks if an exception is a transient error.
50
50
 
51
51
  The following server errors are considered transient:
52
+ - rbx.exceptions.RequestTimeout
53
+ - rbx.exceptions.ServerError
54
+ - rbx.exceptions.TooManyRequests
52
55
  - rbx.exceptions.TransientException
53
- - rbx.exceptions.TransientServerError
54
56
  """
55
57
  if_transient_error = if_exception_type(
58
+ exceptions.RequestTimeout,
59
+ exceptions.ServerError,
60
+ exceptions.TooManyRequests,
56
61
  exceptions.TransientException,
57
- exceptions.TransientServerError,
58
62
  )
59
63
 
60
64
 
@@ -72,12 +72,14 @@ class Forbidden(ClientException):
72
72
  status_code = 403
73
73
 
74
74
 
75
- class ServerError(ClientException):
76
- """5xx server errors."""
75
+ class RequestTimeout(ClientException):
76
+ message = "Request Timeout"
77
+ status_code = 408
77
78
 
78
79
 
79
- class TransientServerError(ClientException):
80
- """Transient 5xx server errors."""
80
+ class TooManyRequests(ClientException):
81
+ message = "Too Many Requests"
82
+ status_code = 429
81
83
 
82
84
 
83
85
  class Unauthorized(ClientException):
@@ -104,6 +106,10 @@ class RetryError(ClientException):
104
106
  return f"{self.message}, last exception: {self.cause}"
105
107
 
106
108
 
109
+ class ServerError(HTTPException):
110
+ """5xx server errors."""
111
+
112
+
107
113
  class TransientException(Exception):
108
114
  """Raise this exception when we know the cause is transient (e.g.: connection errors,
109
115
  consistency error, ...).
@@ -4,7 +4,7 @@ from flask import jsonify, request
4
4
  from google.cloud.error_reporting import Client
5
5
  from google.cloud.error_reporting.util import build_flask_context
6
6
 
7
- from ..exceptions import BadRequest
7
+ from ..exceptions import BadRequest, TransientException
8
8
 
9
9
 
10
10
  def register_error_handlers(app):
@@ -46,12 +46,24 @@ def register_error_handlers(app):
46
46
  response.status_code = 405
47
47
  return response
48
48
 
49
+ @app.errorhandler(408)
50
+ def request_timeout(error):
51
+ response = jsonify(message="Request Timeout")
52
+ response.status_code = 408
53
+ return response
54
+
49
55
  @app.errorhandler(415)
50
56
  def unsupported_media_type(error):
51
57
  response = jsonify(message="Unsupported Media Type")
52
58
  response.status_code = 415
53
59
  return response
54
60
 
61
+ @app.errorhandler(429)
62
+ def too_many_requests(error):
63
+ response = jsonify(message="Too Many Requests")
64
+ response.status_code = 429
65
+ return response
66
+
55
67
  # BadRequest exceptions
56
68
  @app.errorhandler(BadRequest)
57
69
  def invalid_exception(error):
@@ -60,6 +72,13 @@ def register_error_handlers(app):
60
72
  response.status_code = error.status_code
61
73
  return response
62
74
 
75
+ # TransientException exceptions
76
+ @app.errorhandler(TransientException)
77
+ def transient_exception(error):
78
+ response = jsonify(message="Request Timeout")
79
+ response.status_code = 408
80
+ return response
81
+
63
82
  # Uncaught exceptions
64
83
  @app.errorhandler(Exception)
65
84
  def unhandled_exception(error):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rbx
3
- Version: 3.19.2.dev172
3
+ Version: 3.20.0.dev175
4
4
  Summary: A collection of common tools for Scoota services.
5
5
  Author-email: The Scoota Engineering Team <engineering@scoota.com>
6
6
  License:
@@ -1 +0,0 @@
1
- __version__ = "3.19.2.dev172"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes