Skip to content

Initial database version of languages#8

Merged
hellcp merged 1 commit intopebble-dev:masterfrom
hellcp:database
Apr 19, 2026
Merged

Initial database version of languages#8
hellcp merged 1 commit intopebble-dev:masterfrom
hellcp:database

Conversation

@hellcp
Copy link
Copy Markdown
Member

@hellcp hellcp commented Dec 6, 2025

No description provided.

Comment thread languages/api.py Outdated
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]]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread languages/api.py Outdated
Comment on lines +39 to +48
@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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread languages/api.py Outdated
return 'Not authorized', 410

data = request.form
locale = langcodes.standardize_tag(data.get('locale'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread languages/api.py
Comment on lines +61 to +63
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

@jwise jwise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Comment thread languages/utils.py

parent_app = None

class ObjectIdGenerator:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth hauling this into rws-common

Comment thread languages/s3.py

_clients = {}

def _client_for_endpoint(endpoint):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also probably worth hauling this into rws-common

Copy link
Copy Markdown
Contributor

@jwise jwise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@hellcp hellcp merged commit bf45143 into pebble-dev:master Apr 19, 2026
aveao added a commit to aveao/rebble-cohorts that referenced this pull request Apr 21, 2026
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.
aveao added a commit to aveao/rebble-cohorts that referenced this pull request Apr 21, 2026
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.
aveao added a commit to aveao/rebble-cohorts that referenced this pull request Apr 21, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants