22 Commits

Author SHA1 Message Date
Kenneth Kehl
99585ae9f0 try to force gevent monkey patching earlier 2025-07-28 11:17:00 -07:00
Kenneth Kehl
6f663c83eb add gevent monkeypatching 2025-07-28 10:01:44 -07:00
Kenneth Kehl
23e10b1529 tuple 2025-02-05 10:56:32 -08:00
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
stvnrlly
e12e780a05 code cleanup 2022-11-28 15:53:56 -05:00
Ben Thorner
3c3bc71cc0 Revert "Trial running Sentry in Admin"
This reverts commit 5ae8acb8aa.
2022-01-05 14:35:49 +00:00
Ben Thorner
7f0ab3d1db Tweak Sentry config to work in development
This makes a couple of changes:

- Most importantly, it wraps the setup code in a conditional so that
developers don't need to have a DSN set to start the app locally.

- Secondly, it removes the redundant call to "set_level". Originally
I thought the integration was sending info/warning events, but this
isn't the case [1] and even if it was, "set_level" affects the level
of custom events [2], not the level they are dispatched at.

[1]: 4c09f3203d/sentry_sdk/integrations/logging.py (L56)
[2]: https://docs.sentry.io/platforms/python/guides/logging/usage/set-level/
2022-01-04 11:53:26 +00:00
Ben Thorner
1bc174d357 Add RedisIntegration to Sentry trial
This should expose additional performance stats.
2021-12-31 17:43:10 +00:00
Ben Thorner
d752b0b83a Silence errors from Python Client
Otherwise we start spamming Sentry with every 404 error log. Even
if the erorr is a 5xx, it depends on how we handle it in the calling
code as to whether we would want to consider it an error.

I didn't spot this in initial testing on Preview because the 404s in
Preview are only triggered due to the functional tests, which only run
when we're deploying something.

Arguably we shouldn't be logging at error level in our Python Client,
since we're also raising an exception [1]. But changing that would be
a can of worms as it's not an internal-only library.

[1]: 74a958de00/notifications_python_client/base.py (L118)
2021-12-31 12:04:35 +00:00
Ben Thorner
5ae8acb8aa Trial running Sentry in Admin
This will capture and send various events to Sentry:

- Any unhandled exceptions.
- Any logger.error calls.
- Some request traces.

The latter are severely limited to avoid going over the free tier
limits for Sentry, and to avoid excess effort on our end.
2021-12-31 10:57:05 +00:00
David McDonald
3e80ba4734 Fix flake8 and isort errors
Note, isort now has default behaviour of searching recursively so we no
longer need the `-rc` flag
2021-03-08 18:48:56 +00:00
Chris Hill-Scott
23d00aacfd Remove WhiteNoise
We’re now serving assets from S3 when running on PaaS. So we’ll set
the appropriate caching headers there or in Cloudfront. This means that
the app no longer needs to serve cache headers, which is what we were
using WhiteNoise for.

This commits removes WhiteNoise in favour of letting Flask handle the
serving of static assets.
2018-12-21 10:44:20 +00:00
Chris Hill-Scott
58d3d70a7c Expose application as a variable
This is what Gunicorn is looking for when it’s running the app.

Renaming this variable to `app` has caused the app to break once
deployed on PaaS.

This commit also renames `app` to `flask_app` to make it clear which
app is wrapping which other app.
2018-11-29 14:02:20 +00:00
Chris Hill-Scott
d47e0482d4 Tell browsers not to re-fetch static assets
Since we version our asset filenames there’s no need for a browser to
ever fetch the same file twice. It should always cache fetch from its
own cache.

The accepted way to effect this behaviour is using the expires header,
which is what this argument to `WhiteNoise` does.
2018-11-29 13:22:52 +00:00
Chris Hill-Scott
d58c04d974 Make Whitenoise serve static assets
Currently it’s not configured properly, so isn’t having any effect.
This change makes it wrap the Flask app, so it intercepts any requests
for static content.

Follows the pattern documented in http://whitenoise.evans.io/en/stable/flask.html#enable-whitenoise
2018-11-29 13:22:52 +00:00
Leo Hemsted
2cd77e628e remove wsgi.py - always serve with whitenoise
We're now running our app as a wsgi app locally, so don't need to
distinguish between the two processes by having wsgi and application.py
whitenoise just serves static files nicely - we don't lose anything
by doing that locally.
2017-11-07 11:50:13 +00:00
Leo Hemsted
4aeb57567a remove flask-script
flask-script has been deprecated by the internal flask.cli module, but
making this carries a few changes with it

* you should add FLASK_APP=application.py and FLASK_DEBUG=1 to your
  environment.sh.
* instead of using `python app.py runserver`, now you must run
  `flask run -p 6012`. The -p command is important - the port must be
  set before the config is loaded, so that it can live reload nicely.
  (https://github.com/pallets/flask/issues/2113#issuecomment-268014481)
* find available commands by just running `flask`.
* run them using flask. eg `flask list_routes`
* define new tasks by giving them the decorator
  `@app.cli.command('task-name')`. Task name isn't needed if it's just
  the same as the function name. Alternatively, if app isn't available
  in the current scope, you can invoke the decorator directly, as seen
  in app/commands.py
2017-11-06 17:33:04 +00:00
Rebecca Law
ecbf641eef Fix the submodule 2015-11-23 16:18:33 +00:00
Rebecca Law
d6c81d581d Start to create views 2015-11-20 16:22:44 +00:00
Rebecca Law
96dd866e6f Add Procfile for heroku 2015-11-20 15:36:47 +00:00
Rebecca Law
83a1dbd79d Added a blank test 2015-11-18 16:52:43 +00:00
Rebecca Law
29012c78ee Initial creation of notify-admin-frontend 2015-11-18 16:19:40 +00:00