Initial database version of languages#8
Conversation
| packs = packs.filter_by(hardware=hardware) | ||
| firmware = request.args.get('firmware') | ||
| if firmware: | ||
| firmware_major, firmware_minor = [int(part) for part in firmware.split('.')[:2]] |
There was a problem hiding this comment.
could be good to wrap this in a try/except so that this gives a 400 instead of a 500 and stackdriver log if someone provides bad params here
| @api.route('/languages/submit', methods=['POST']) | ||
| def submit_language_pack(): | ||
| secret_key = '' | ||
| header = request.headers.get('Authorization') | ||
| if header: | ||
| auth = header.split(' ') | ||
| if len(auth) == 2 and auth[0] == 'Bearer': | ||
| secret_key = auth[1] | ||
| if secret_key != config['SECRET_KEY']: | ||
| return 'Not authorized', 410 |
There was a problem hiding this comment.
this is traditionally not we what we use SECRET_KEY for -- how about having this be a click command instead that gets run locally on someone's machine, for now?
| return 'Not authorized', 410 | ||
|
|
||
| data = request.form | ||
| locale = langcodes.standardize_tag(data.get('locale')) |
There was a problem hiding this comment.
do we want to normalize this here, or just declare that trusted users should prenormalize them? (f.e., would this do the thing requested in coredevices/mobileapp#63?)
There was a problem hiding this comment.
This is in general a bit of a mess because per the standard, the codes should be written with dashes, but are written with underscores instead (and this will turn them into dashes). This does also accept en_Cyrl, which is what my preference would be for the tag for the cyrillic pack, but on the other other hand I really want to see individual translations for all the languages that use cyrillic instead (and eventual inclusion of cyrillic in the base firmware as well)
There was a problem hiding this comment.
Case in point, whenever this is actually deployed we will end up in a situation where ru_RU pack is no longer lying, and the language that it says it is is going to be what it is
| language_name = langcodes.Language.get(locale).display_name() | ||
| local_name = langcodes.Language.get(locale).display_name(locale) | ||
| language = Language(locale=locale, name=language_name, local_name=local_name) |
There was a problem hiding this comment.
same question as to whether this does what we want for Pebble language codes that do not add languages, but just character sets -- maybe best left to the trusted user
jwise
left a comment
There was a problem hiding this comment.
This is fine with me, though I would rather that uploads just happen from the command line for now, but this is not publicly exposed or committed to at least...
|
|
||
| parent_app = None | ||
|
|
||
| class ObjectIdGenerator: |
There was a problem hiding this comment.
probably worth hauling this into rws-common
|
|
||
| _clients = {} | ||
|
|
||
| def _client_for_endpoint(endpoint): |
There was a problem hiding this comment.
also probably worth hauling this into rws-common
jwise
left a comment
There was a problem hiding this comment.
I did not look all that closely, but this seems benign and does not seem to lock us into any particular thing in the future, so if you test it and it works, go for it. some style nits (mostly DRY into rws-common)
Firmwares now live in a `firmwares` table keyed by (hardware, kind, version) rather than being read from config.json at import time. /cohort?select=fw returns the latest row per kind ordered by timestamp, so multiple versions per (hardware, kind) are allowed and rollbacks work by submitting an older version with a newer timestamp. config.json stays in-repo only as seed data for the new `flask import_json` CLI command; future edits go through `flask submit_firmware HARDWARE KIND VERSION URL SHA256 [--timestamp] [--notes]`. Follows the pattern in pebble-dev/rebble-lp#8 minus S3 (firmware blobs stay on the CDN) and rws-common (deferred). Deployments now need DATABASE_URL set and `flask db upgrade` run before serving; see README.
Firmwares now live in a `firmwares` table keyed by (hardware, kind, version) rather than being read from config.json at import time. /cohort?select=fw returns the latest row per kind ordered by timestamp, so multiple versions per (hardware, kind) are allowed and rollbacks work by submitting an older version with a newer timestamp. config.json stays in-repo only as seed data for the new `flask import_json` CLI command; future edits go through `flask submit_firmware HARDWARE KIND VERSION URL SHA256 [--timestamp] [--notes]`. Follows the pattern in pebble-dev/rebble-lp#8 minus S3 (firmware blobs stay on the CDN) and rws-common (deferred). Deployments now need DATABASE_URL set and `flask db upgrade` run before serving; see README.
Firmwares now live in a `firmwares` table keyed by (hardware, kind, version) rather than being read from config.json at import time. /cohort?select=fw returns the latest row per kind ordered by timestamp, so multiple versions per (hardware, kind) are allowed and rollbacks work by submitting an older version with a newer timestamp. config.json stays in-repo only as seed data for the new `flask import_json` CLI command; future edits go through `flask submit_firmware HARDWARE KIND VERSION URL SHA256 [--timestamp] [--notes]`. Follows the pattern in pebble-dev/rebble-lp#8 minus S3 (firmware blobs stay on the CDN) and rws-common (deferred). Deployments now need DATABASE_URL set and `flask db upgrade` run before serving; see README.
No description provided.