rbx 3.22.1.dev186__tar.gz → 3.22.2__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 (46) hide show
  1. {rbx-3.22.1.dev186 → rbx-3.22.2}/PKG-INFO +1 -1
  2. {rbx-3.22.1.dev186 → rbx-3.22.2}/pyproject.toml +2 -2
  3. rbx-3.22.2/rbx/__init__.py +1 -0
  4. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/clients/__init__.py +2 -13
  5. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/clients/place.py +0 -23
  6. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/web/handlers.py +27 -7
  7. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx.egg-info/PKG-INFO +1 -1
  8. rbx-3.22.1.dev186/rbx/__init__.py +0 -1
  9. {rbx-3.22.1.dev186 → rbx-3.22.2}/LICENSE +0 -0
  10. {rbx-3.22.1.dev186 → rbx-3.22.2}/README.md +0 -0
  11. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/auth/__init__.py +0 -0
  12. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/auth/decorators.py +0 -0
  13. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/auth/id_token.py +0 -0
  14. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/auth/keystore.py +0 -0
  15. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/auth/mock.py +0 -0
  16. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/aws/__init__.py +0 -0
  17. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/aws/s3.py +0 -0
  18. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/buildtools/__init__.py +0 -0
  19. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/buildtools/cli.py +0 -0
  20. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/buildtools/tasks/__init__.py +0 -0
  21. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/buildtools/tasks/ec2.py +0 -0
  22. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/buildtools/tasks/image.py +0 -0
  23. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/buildtools/tasks/misc.py +0 -0
  24. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/clients/adsquare.py +0 -0
  25. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/clients/broadsign.py +0 -0
  26. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/clients/oxr.py +0 -0
  27. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/clients/panels.py +0 -0
  28. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/clients/reporting.py +0 -0
  29. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/clients/retry.py +0 -0
  30. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/exceptions.py +0 -0
  31. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/gcp/__init__.py +0 -0
  32. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/gcp/cloud_tasks.py +0 -0
  33. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/gcp/pubsub.py +0 -0
  34. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/gcp/storage.py +0 -0
  35. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/logging.py +0 -0
  36. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/settings.py +0 -0
  37. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/utils/__init__.py +0 -0
  38. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/utils/mdm.py +0 -0
  39. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/utils/vast.py +0 -0
  40. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx/web/__init__.py +0 -0
  41. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx.egg-info/SOURCES.txt +0 -0
  42. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx.egg-info/dependency_links.txt +0 -0
  43. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx.egg-info/entry_points.txt +0 -0
  44. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx.egg-info/requires.txt +0 -0
  45. {rbx-3.22.1.dev186 → rbx-3.22.2}/rbx.egg-info/top_level.txt +0 -0
  46. {rbx-3.22.1.dev186 → rbx-3.22.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rbx
3
- Version: 3.22.1.dev186
3
+ Version: 3.22.2
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.22.1.dev186"
7
+ version = "3.22.2"
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.22.1.dev186"
83
+ current_version = "3.22.2"
84
84
  commit = true
85
85
  parse = """
86
86
  (?P<major>\\d+)\\.
@@ -0,0 +1 @@
1
+ __version__ = "3.22.2"
@@ -124,7 +124,6 @@ class Client(metaclass=Singleton):
124
124
  headers=None,
125
125
  params=None,
126
126
  timeout=None,
127
- include_headers=False,
128
127
  ):
129
128
  """Wrap the method call in common error handling."""
130
129
  endpoint = endpoint if endpoint is not None else self.ENDPOINT
@@ -218,15 +217,13 @@ class Client(metaclass=Singleton):
218
217
 
219
218
  # 204 "No Content" responses return nothing
220
219
  if response.status_code == 204:
221
- if include_headers:
222
- return {"content": None, "headers": dict(response.headers)}
223
220
  return
224
221
 
225
222
  if content_type == "text/plain":
226
- content = response.text
223
+ return response.text
227
224
  else:
228
225
  try:
229
- content = self.get_response(response)
226
+ return self.get_response(response)
230
227
  except ValueError:
231
228
  extra = {
232
229
  "request": payload,
@@ -236,12 +233,6 @@ class Client(metaclass=Singleton):
236
233
  "Invalid JSON response", details=extra, status_code=500, url=url
237
234
  )
238
235
 
239
- # Return content with headers if requested, otherwise just content
240
- if include_headers:
241
- return {"content": content, "headers": dict(response.headers)}
242
- else:
243
- return content
244
-
245
236
  def request(
246
237
  self,
247
238
  method,
@@ -252,7 +243,6 @@ class Client(metaclass=Singleton):
252
243
  headers=None,
253
244
  params=None,
254
245
  timeout=None,
255
- include_headers=False,
256
246
  ):
257
247
  """Attempt to re-authenticate when the token has expired.
258
248
 
@@ -271,7 +261,6 @@ class Client(metaclass=Singleton):
271
261
  headers=headers,
272
262
  params=params,
273
263
  timeout=timeout,
274
- include_headers=include_headers,
275
264
  )
276
265
 
277
266
  try:
@@ -275,26 +275,3 @@ class PlaceExchangeClient(Client):
275
275
  path=path,
276
276
  params=params if params else None,
277
277
  )
278
-
279
- def get_screens(self, page=None):
280
- """Retrieve a page of screens from Place Exchange."""
281
- path = f"v3/orgs/{self.org_id}/avails"
282
- params = {"page_size": 1000}
283
-
284
- if page:
285
- params["page"] = page
286
-
287
- response = self.request("get", path, params=params, include_headers=True)
288
-
289
- # Extract the page for the next page from the Link header if it exists
290
- next_page = None
291
- if "Link" in response["headers"]:
292
- links = response["headers"]["Link"].split(",")
293
- for link in links:
294
- if "rel='next'" in link:
295
- # Extract the page parameter from the URL
296
- url_part = link.split(";")[0].strip("<>")
297
- if "page=" in url_part:
298
- next_page = int(url_part.split("page=")[1].split("&")[0])
299
-
300
- return response["content"], next_page
@@ -1,10 +1,11 @@
1
+ import traceback
1
2
  import os
2
3
 
3
4
  from flask import jsonify, request
4
5
  from google.cloud.error_reporting import Client
5
6
  from google.cloud.error_reporting.util import build_flask_context
6
7
 
7
- from ..exceptions import BadRequest, TransientException
8
+ from ..exceptions import BadRequest, FatalException, TransientException
8
9
 
9
10
 
10
11
  def register_error_handlers(app):
@@ -20,6 +21,11 @@ def register_error_handlers(app):
20
21
 
21
22
  >>> raise BadRequest('Message')
22
23
 
24
+ Important: the `PYTHONNODEBUGRANGES` environment variable must be set for the traceback
25
+ to be formatted in a format Google App Reporting understands.
26
+
27
+ >>> PYTHONNODEBUGRANGES=1
28
+
23
29
  """
24
30
 
25
31
  @app.errorhandler(401)
@@ -79,15 +85,18 @@ def register_error_handlers(app):
79
85
  response.status_code = 408
80
86
  return response
81
87
 
88
+ # FatalException exceptions
89
+ @app.errorhandler(FatalException)
90
+ def fatal_exception(error):
91
+ report_exception(app)
92
+ response = jsonify(message=str(error))
93
+ response.status_code = 500
94
+ return response
95
+
82
96
  # Uncaught exceptions
83
97
  @app.errorhandler(Exception)
84
98
  def unhandled_exception(error):
85
- if os.getenv("GAE_ENV", "").startswith("standard"):
86
- client = Client()
87
- client.report_exception(http_context=build_flask_context(request))
88
- else:
89
- app.logger.exception(f"Unhandled Exception: {error}")
90
-
99
+ report_exception(app)
91
100
  response = jsonify(
92
101
  message="Something went wrong!",
93
102
  details=[
@@ -98,3 +107,14 @@ def register_error_handlers(app):
98
107
  )
99
108
  response.status_code = 500
100
109
  return response
110
+
111
+
112
+ def report_exception(app, message=None):
113
+ context = build_flask_context(request)
114
+ context.responseStatusCode = 500
115
+ message = message or traceback.format_exc()
116
+
117
+ if os.getenv("GAE_ENV", "").startswith("standard"):
118
+ Client().report(message, http_context=context)
119
+ else:
120
+ app.logger.error(message)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rbx
3
- Version: 3.22.1.dev186
3
+ Version: 3.22.2
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.22.1.dev186"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes