"]
6 | license = "GNU AGPL 3.0"
7 |
8 | [tool.poetry.dependencies]
9 | python = "^3.9"
10 | facebook-sdk = "*"
11 | # Version 1.0 of flask required because later versions do not allow lists to be passed as API repsonses. The Google
12 | # STT endpoint passes a list of transcriptions to the device. Changing this to return a dictionary would break the
13 | # API's V1 contract with Mycroft Core.
14 | #
15 | # To make flask 1.0 work, older versions of itsdangerous, jinja2 and markupsafe are required.
16 | email-validator = "*"
17 | flask = "<1.1"
18 | itsdangerous = "<=2.0.1"
19 | jinja2 = "<=2.10.1"
20 | markupsafe = "<=2.0.1"
21 | paramiko = "*"
22 | passlib = "*"
23 | psycopg2-binary = "*"
24 | pygithub = "*"
25 | pyjwt = "*"
26 | redis = "*"
27 | schedule = "*"
28 | schematics = "*"
29 | sendgrid = "*"
30 | stripe = "*"
31 | werkzeug = "<=2.0.3"
32 |
33 | [tool.poetry.dev-dependencies]
34 | black = "*"
35 | pyhamcrest = "*"
36 | pylint = "*"
37 |
38 | [build-system]
39 | requires = ["poetry-core>=1.0.0"]
40 | build-backend = "poetry.core.masonry.api"
41 |
--------------------------------------------------------------------------------
/shared/selene/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/api/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from .base_config import get_base_config
21 | from .base_endpoint import APIError, SeleneEndpoint
22 | from .blueprint import selene_api
23 | from .etag import device_etag_key, device_setting_etag_key, ETagManager
24 | from .public_endpoint import PublicEndpoint, track_account_activity
25 | from .public_endpoint import generate_device_login
26 | from .response import SeleneResponse, snake_to_camel
27 |
--------------------------------------------------------------------------------
/shared/selene/api/endpoints/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Public API for the selene.api.endpoints package."""
20 |
21 | from .account import AccountEndpoint
22 | from .agreements import AgreementsEndpoint
23 | from .password_change import PasswordChangeEndpoint
24 | from .validate_email import ValidateEmailEndpoint
25 |
--------------------------------------------------------------------------------
/shared/selene/batch/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from .base import SeleneScript
21 |
--------------------------------------------------------------------------------
/shared/selene/data/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/account/entity/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/account/entity/agreement.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from datetime import date
22 |
23 | TERMS_OF_USE = "Terms of Use"
24 | PRIVACY_POLICY = "Privacy Policy"
25 | OPEN_DATASET = "Open Dataset"
26 |
27 |
28 | @dataclass
29 | class Agreement(object):
30 | type: str
31 | version: str
32 | effective_date: date
33 | id: str = None
34 | content: str = None
35 |
--------------------------------------------------------------------------------
/shared/selene/data/account/entity/membership.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from decimal import Decimal
22 |
23 |
24 | @dataclass
25 | class Membership(object):
26 | type: str
27 | rate: Decimal
28 | rate_period: str
29 | stripe_plan: str
30 | id: str = None
31 |
--------------------------------------------------------------------------------
/shared/selene/data/account/entity/skill.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from typing import List
22 |
23 |
24 | @dataclass
25 | class AccountSkill(object):
26 | skill_id: str
27 | skill_name: str
28 | devices: List[str]
29 | display_name: str = None
30 | settings_version: str = None
31 | settings_display: dict = None
32 | settings: dict = None
33 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/add_account.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | account.account (email_address, password, username)
3 | VALUES
4 | (%(email_address)s, %(password)s, %(username)s)
5 | RETURNING
6 | id
7 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/add_account_agreement.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | account.account_agreement (account_id, agreement_id, accept_date)
3 | VALUES
4 | (
5 | %(account_id)s,
6 | (
7 | SELECT
8 | id
9 | FROM
10 | account.agreement
11 | WHERE
12 | agreement = %(agreement_name)s
13 | AND effective @> CURRENT_DATE
14 | ),
15 | '[now,]'
16 | )
17 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/add_account_membership.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | account.account_membership (
3 | account_id,
4 | membership_id,
5 | membership_ts_range,
6 | payment_method,
7 | payment_account_id,
8 | payment_id
9 | )
10 | VALUES
11 | (
12 | %(account_id)s,
13 | (
14 | SELECT
15 | id
16 | FROM
17 | account.membership
18 | WHERE
19 | type = %(membership_type)s
20 | ),
21 | '[now,]',
22 | %(payment_method)s,
23 | %(payment_account_id)s,
24 | %(payment_id)s
25 | )
26 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/add_agreement.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | account.agreement (agreement, version, effective, content_id)
3 | VALUES
4 | (%(agreement_type)s, %(version)s, %(date_range)s, %(content_id)s)
5 | RETURNING
6 | id
7 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/add_membership.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | account.membership (type, rate, rate_period)
3 | VALUES
4 | (%(membership_type)s, %(rate)s, %(rate_period)s)
5 | RETURNING
6 | id
7 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/change_email_address.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | account.account
3 | SET
4 | email_address = %(email_address)s
5 | WHERE
6 | id = %(account_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/change_password.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | account.account
3 | SET
4 | password = %(password)s
5 | WHERE
6 | id = %(account_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/delete_agreement.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | account.agreement
3 | WHERE
4 | id = %(agreement_id)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/delete_membership.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | account.membership
3 | WHERE
4 | id = %(membership_id)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/end_membership.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | account.account_membership
3 | SET
4 | membership_ts_range = %(membership_ts_range)s
5 | WHERE
6 | id = %(id)s
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/expire_account_agreement.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | account.account_agreement
3 | WHERE
4 | account_id = %(account_id)s
5 | AND agreement_id in (SELECT id FROM account.agreement WHERE agreement = %(agreement_type)s)
6 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/expire_agreement.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | account.agreement
3 | SET
4 | effective = %(date_range)s
5 | WHERE
6 | agreement = %(agreement_type)s
7 | AND upper(effective) IS NULL
8 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/get_account_skills.sql:
--------------------------------------------------------------------------------
1 | -- get all combinations of skills and skill setting meta for an account
2 | WITH
3 | skills AS (
4 | SELECT
5 | s.id AS skill_id,
6 | s.name AS skill_name,
7 | ds.skill_setting_meta_id,
8 | ds.settings::jsonb,
9 | array_agg(d.name) AS devices
10 | FROM
11 | skill.skill s
12 | INNER JOIN device.device_skill ds ON ds.skill_id = s.id
13 | INNER JOIN device.device d ON d.id = ds.device_id
14 | WHERE
15 | d.account_id = %(account_id)s
16 | GROUP BY
17 | s.id,
18 | s.name,
19 | ds.skill_setting_meta_id,
20 | ds.settings::jsonb
21 | ),
22 | skill_meta AS (
23 | SELECT
24 | skill_id,
25 | display_name,
26 | max(branch)
27 | FROM
28 | skill.branch
29 | GROUP BY
30 | skill_id,
31 | display_name
32 | )
33 | SELECT
34 | s.skill_id,
35 | s.skill_name,
36 | s.settings,
37 | s.devices,
38 | skm.display_name,
39 | sm.version AS settings_version,
40 | sm.settings_meta
41 | FROM
42 | skills s
43 | LEFT JOIN skill.setting_meta sm ON s.skill_setting_meta_id = sm.id
44 | LEFT JOIN skill_meta skm ON skm.skill_id = s.skill_id
45 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/get_active_membership_by_account_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | acc_mem.id,
3 | mem.type,
4 | LOWER(acc_mem.membership_ts_range)::date start_date,
5 | acc_mem.payment_method,
6 | payment_account_id,
7 | payment_id
8 | FROM
9 | account.account_membership acc_mem
10 | INNER JOIN
11 | account.membership mem ON acc_mem.membership_id = mem.id
12 | WHERE
13 | account_id = %(account_id)s AND UPPER(acc_mem.membership_ts_range) IS NULL
14 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/get_active_membership_by_payment_account_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | acc_mem.id,
3 | mem.type,
4 | LOWER(acc_mem.membership_ts_range)::date start_date,
5 | acc_mem.payment_method,
6 | payment_account_id,
7 | payment_id
8 | FROM
9 | account.account_membership acc_mem
10 | INNER JOIN
11 | account.membership mem ON acc_mem.membership_id = mem.id
12 | WHERE
13 | acc_mem.payment_account_id = %(payment_account_id)s AND UPPER(acc_mem.membership_ts_range) IS NULL
14 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/get_agreement_content_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | content_id
3 | FROM
4 | account.agreement
5 | WHERE
6 | id = %(agreement_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/get_current_agreements.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | agreement,
4 | version,
5 | content_id,
6 | lower(effective) as effective_date
7 | FROM
8 | account.agreement
9 | WHERE
10 | effective @> CURRENT_DATE
11 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/get_membership_by_type.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | type,
4 | rate,
5 | rate_period,
6 | stripe_plan
7 | FROM
8 | account.membership
9 | WHERE
10 | type = %(type)s
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/get_membership_types.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | type,
4 | rate,
5 | rate_period,
6 | stripe_plan
7 | FROM
8 | account.membership
9 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/remove_account.sql:
--------------------------------------------------------------------------------
1 | -- Perform a cascading delete on an account. All children of the account
2 | -- table should have ON DELETE CASCADE clauses. If this request fails, a missing
3 | -- ON DELETE CASCADE clause may be the culprit.
4 | DELETE FROM
5 | account.account
6 | WHERE
7 | id = %(id)s
8 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/update_last_activity_ts.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | account.account
3 | SET
4 | last_activity_ts = %(last_activity_ts)s
5 | WHERE
6 | id = %(account_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/account/repository/sql/update_username.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | account.account
3 | SET
4 | username = %(username)s
5 | WHERE
6 | id = %(account_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/device/entity/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/device/entity/geography.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from decimal import Decimal
22 |
23 |
24 | @dataclass
25 | class Geography(object):
26 | country: str
27 | region: str
28 | city: str
29 | time_zone: str
30 | latitude: Decimal = None
31 | longitude: Decimal = None
32 | id: str = None
33 |
--------------------------------------------------------------------------------
/shared/selene/data/device/entity/preference.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class AccountPreferences(object):
25 | date_format: str
26 | time_format: str
27 | measurement_system: str
28 | id: str = None
29 |
--------------------------------------------------------------------------------
/shared/selene/data/device/entity/text_to_speech.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class TextToSpeech(object):
25 | setting_name: str
26 | display_name: str
27 | engine: str
28 | id: str = None
29 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from .device import Device
21 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/add_device.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | device.device (account_id, name, placement, wake_word_id, text_to_speech_id, geography_id)
3 | VALUES
4 | (
5 | %(account_id)s,
6 | %(name)s,
7 | %(placement)s,
8 | (SELECT id FROM wake_word.wake_word WHERE name = %(wake_word)s ORDER BY engine DESC LIMIT 1),
9 | (SELECT id FROM device.text_to_speech WHERE display_name = %(voice)s),
10 | %(geography_id)s
11 | )
12 | RETURNING id
13 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/add_geography.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | device.geography (account_id, country_id, region_id, city_id, timezone_id)
3 | VALUES
4 | (
5 | %(account_id)s,
6 | (SELECT id FROM geography.country WHERE name = %(country)s),
7 | (
8 | SELECT
9 | r.id
10 | FROM
11 | geography.region r
12 | INNER JOIN geography.country c ON c.id = r.country_id
13 | WHERE
14 | r.name = %(region)s
15 | AND c.name = %(country)s
16 | ),
17 | (
18 | SELECT
19 | c.id
20 | FROM
21 | geography.city c
22 | INNER JOIN geography.region r ON r.id = c.region_id
23 |
24 | WHERE
25 | c.name = %(city)s
26 | AND r.name = %(region)s
27 | ),
28 | (SELECT id FROM geography.timezone WHERE name = %(timezone)s)
29 | )
30 | RETURNING
31 | id
32 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/add_manifest_skill.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | device.device_skill (
3 | device_id,
4 | skill_id,
5 | install_method,
6 | install_status,
7 | install_failure_reason,
8 | install_ts,
9 | update_ts
10 | )
11 | VALUES
12 | (
13 | %(device_id)s,
14 | %(skill_id)s,
15 | %(install_method)s,
16 | %(install_status)s,
17 | %(install_failure_reason)s,
18 | %(install_ts)s,
19 | %(update_ts)s
20 | )
21 | RETURNING
22 | id
23 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/add_text_to_speech.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | device.text_to_speech (setting_name, display_name, engine)
3 | VALUES
4 | (%(setting_name)s, %(display_name)s, %(engine)s)
5 | RETURNING id
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/delete_device_skill.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | device.device_skill
3 | WHERE
4 | device_id = %(device_id)s
5 | AND skill_id = %(skill_id)s
6 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_account_device_count.sql:
--------------------------------------------------------------------------------
1 | SELECT count(*) AS device_count FROM device.device WHERE account_id = %(account_id)s
2 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_account_geographies.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | g.id,
3 | cntry.name AS country,
4 | r.name as region,
5 | cty.name AS city,
6 | t.name as time_zone,
7 | latitude,
8 | longitude
9 | FROM
10 | device.geography g
11 | INNER JOIN geography.city cty ON g.city_id = cty.id
12 | INNER JOIN geography.country cntry ON g.country_id = cntry.id
13 | INNER JOIN geography.region r ON g.region_id = r.id
14 | INNER JOIN geography.timezone t ON g.timezone_id = t.id
15 | WHERE
16 | account_id = %(account_id)s
17 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_account_preferences.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | measurement_system,
4 | date_format,
5 | time_format
6 | FROM
7 | device.account_preferences
8 | WHERE
9 | account_id = %(account_id)s
10 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_all_device_ids.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id
3 | FROM
4 | device.device
5 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_device_settings_by_device_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | acc.id as uuid,
3 | acc.measurement_system as system_unit,
4 | acc.date_format as date_format,
5 | acc.time_format as time_format,
6 | json_build_object('setting_name', tts.setting_name, 'engine', tts.engine) as tts_settings,
7 | json_build_object(
8 | 'uuid', ps.id,
9 | 'sampleRate', ps.sample_rate,
10 | 'channels', ps.channels,
11 | 'wakeWord', ww.name,
12 | 'phonemes', ps.pronunciation,
13 | 'threshold', ps.threshold,
14 | 'multiplier', ps.threshold_multiplier,
15 | 'energyRatio', ps.dynamic_energy_ratio) as listener_setting
16 | FROM
17 | device.device dev
18 | INNER JOIN
19 | device.account_preferences acc ON dev.account_id = acc.account_id
20 | INNER JOIN
21 | device.text_to_speech tts ON dev.text_to_speech_id = tts.id
22 | INNER JOIN
23 | wake_word.wake_word ww ON dev.wake_word_id = ww.id
24 | LEFT JOIN
25 | wake_word.pocketsphinx_settings ps ON ww.id = ps.wake_word_id
26 | WHERE
27 | dev.id = %(device_id)s
28 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_device_skill_manifest.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | ds.id,
3 | ds.device_id,
4 | ds.install_failure_reason,
5 | ds.install_method,
6 | ds.install_status,
7 | ds.install_ts,
8 | ds.skill_id,
9 | ds.update_ts,
10 | s.skill_gid
11 | FROM
12 | device.device d
13 | INNER JOIN device.device_skill ds ON d.id = ds.device_id
14 | INNER JOIN skill.skill s ON ds.skill_id = s.id
15 | WHERE
16 | d.id = %(device_id)s
17 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_location_by_device_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | json_build_object(
3 | 'latitude', city.latitude,
4 | 'longitude', city.longitude
5 | ) as coordinate,
6 | json_build_object(
7 | 'name', timezone.name,
8 | 'code', timezone.name,
9 | 'offset', trunc(timezone.gmt_offset * 60 * 60 * 1000),
10 | 'dstOffset', trunc(timezone.dst_offset * 60 * 60 * 1000)
11 | ) as timezone,
12 | json_build_object(
13 | 'name', city.name,
14 | 'state', json_build_object(
15 | 'name', region.name,
16 | 'code', region.region_code,
17 | 'country', json_build_object(
18 | 'name', country.name,
19 | 'code', country.iso_code
20 | )
21 | )
22 | ) as city
23 | FROM
24 | device.device dev
25 | INNER JOIN
26 | device.geography geo ON dev.geography_id = geo.id
27 | INNER JOIN
28 | geography.country country ON geo.country_id = country.id
29 | INNER JOIN
30 | geography.region region ON geo.region_id = region.id
31 | INNER JOIN
32 | geography.city city ON geo.city_id = city.id
33 | INNER JOIN
34 | geography.timezone timezone ON geo.timezone_id = timezone.id
35 | WHERE
36 | dev.id = %(device_id)s
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_open_dataset_agreement_by_device_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | acc_agr.id
3 | FROM
4 | device.device dev
5 | INNER JOIN
6 | account.account acc ON dev.account_id = acc.id
7 | INNER JOIN
8 | account.account_agreement acc_agr ON acc.id = acc_agr.account_id
9 | INNER JOIN
10 | account.agreement agr ON acc_agr.agreement_id = agr.id
11 | WHERE
12 | dev.id = %(device_id)s AND agr.agreement = 'Open Dataset'
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_settings_display_usage.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | count(*) AS usage
3 | FROM
4 | device.device_skill
5 | WHERE
6 | skill_settings_display_id = %(settings_display_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_skill_manifest_for_account.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | ds.device_id,
3 | ds.install_failure_reason,
4 | ds.install_method,
5 | ds.install_status,
6 | ds.install_ts,
7 | ds.skill_id,
8 | ds.update_ts,
9 | s.skill_gid
10 | FROM
11 | device.device d
12 | INNER JOIN device.device_skill ds ON d.id = ds.device_id
13 | INNER JOIN skill.skill s ON ds.skill_id = s.id
14 | WHERE
15 | d.account_id = %(account_id)s
16 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_skill_settings_for_account.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | dds.skill_settings_display_id AS settings_display_id,
3 | dds.settings::jsonb AS settings_values,
4 | dds.install_method,
5 | dds.skill_id,
6 | array_agg(dds.device_id::text) AS device_ids
7 | FROM
8 | device.device dd
9 | INNER JOIN device.device_skill dds ON dd.id = dds.device_id
10 | WHERE
11 | dd.account_id = %(account_id)s
12 | AND dds.skill_id = %(skill_id)s
13 | GROUP BY
14 | dds.skill_settings_display_id,
15 | dds.settings::jsonb,
16 | dds.install_method,
17 | dds.skill_id
18 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_skill_settings_for_device.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | ds.skill_settings_display_id AS settings_display_id,
3 | ds.settings::jsonb AS settings_values,
4 | ds.skill_id,
5 | s.skill_gid
6 | FROM
7 | device.device_skill ds
8 | INNER JOIN skill.skill s ON ds.skill_id = s.id
9 | WHERE
10 | device_id = %(device_id)s
11 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/get_voices.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | setting_name,
4 | display_name,
5 | engine
6 | FROM
7 | device.text_to_speech
8 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/remove_device.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | device.device
3 | WHERE
4 | id = %(device_id)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/remove_manifest_skill.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | device.device_skill
3 | WHERE
4 | device_id = %(device_id)s
5 | AND skill_id = (SELECT id FROM skill.skill WHERE skill_gid = %(skill_gid)s)
6 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/remove_text_to_speech.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | device.text_to_speech
3 | WHERE
4 | id = %(text_to_speech_id)s
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/update_device_from_account.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | device.device
3 | SET
4 | name = %(name)s,
5 | placement = %(placement)s,
6 | geography_id = %(geography_id)s,
7 | wake_word_id = (
8 | SELECT
9 | id
10 | FROM
11 | wake_word.wake_word
12 | WHERE
13 | name = %(wake_word)s
14 | ORDER BY
15 | engine DESC
16 | LIMIT 1
17 | ),
18 | text_to_speech_id = (
19 | SELECT
20 | id
21 | FROM
22 | device.text_to_speech
23 | WHERE
24 | display_name = %(voice)s
25 | )
26 | WHERE
27 | id = %(device_id)s
28 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/update_device_from_core.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | device.device
3 | SET
4 | platform = %(platform)s,
5 | enclosure_version = %(enclosure_version)s,
6 | core_version = %(core_version)s
7 | WHERE
8 | id = %(device_id)s
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/update_device_skill_settings.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | device.device_skill
3 | SET
4 | skill_settings_display_id = %(settings_display_id)s,
5 | settings = %(settings_values)s
6 | WHERE
7 | device_id = %(device_id)s
8 | AND skill_id = %(skill_id)s
9 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/update_last_contact_ts.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | device.device
3 | SET
4 | last_contact_ts = %(last_contact_ts)s
5 | WHERE
6 | id = %(device_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/update_pantacor_config.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | device.pantacor_config
3 | SET
4 | ssh_public_key = %(ssh_public_key)s,
5 | auto_update = %(auto_update)s,
6 | release_channel = %(release_channel)s
7 | WHERE
8 | device_id = %(device_id)s
9 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/update_skill_manifest.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | device.device_skill
3 | SET
4 | install_method = %(install_method)s,
5 | install_status = %(install_status)s,
6 | install_failure_reason = %(failure_message)s,
7 | install_ts = %(install_ts)s,
8 | update_ts = %(update_ts)s
9 | WHERE
10 | device_id = %(device_id)s
11 | AND skill_id = (
12 | SELECT
13 | id
14 | FROM
15 | skill.skill
16 | WHERE
17 | skill_gid = %(skill_gid)s
18 | )
19 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/update_skill_settings.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | device.device_skill
3 | SET
4 | settings = %(settings)s
5 | WHERE
6 | device_id IN (
7 | SELECT
8 | id
9 | FROM
10 | device.device
11 | WHERE
12 | account_id = %(account_id)s AND
13 | device_name IN %(device_names)s
14 | )
15 | AND skill_id = (SELECT id from skill.skill WHERE name = %(skill_name)s)
16 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/upsert_device_skill_settings.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | device.device_skill (
3 | device_id,
4 | skill_id,
5 | skill_settings_display_id,
6 | settings
7 | )
8 | VALUES
9 | (
10 | %(device_id)s,
11 | %(skill_id)s,
12 | %(settings_display_id)s,
13 | %(settings_values)s
14 | )
15 | ON CONFLICT
16 | (device_id, skill_id)
17 | DO UPDATE SET
18 | skill_settings_display_id = %(settings_display_id)s,
19 | settings = %(settings_values)s
20 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/upsert_pantacor_config.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | device.pantacor_config (device_id, pantacor_id, ip_address, auto_update, release_channel)
3 | VALUES
4 | (%(device_id)s, %(pantacor_id)s, %(ip_address)s, %(auto_update)s, %(release_channel)s)
5 | ON CONFLICT
6 | (device_id)
7 | DO UPDATE SET
8 | ip_address = %(ip_address)s
9 |
--------------------------------------------------------------------------------
/shared/selene/data/device/repository/sql/upsert_preferences.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | device.account_preferences(
3 | account_id,
4 | date_format,
5 | time_format,
6 | measurement_system
7 | )
8 | VALUES
9 | (
10 | %(account_id)s,
11 | %(date_format)s,
12 | %(time_format)s,
13 | %(measurement_system)s
14 | )
15 | ON CONFLICT
16 | (account_id)
17 | DO UPDATE SET
18 | date_format = %(date_format)s,
19 | time_format = %(time_format)s,
20 | measurement_system = %(measurement_system)s
21 | RETURNING
22 | id
23 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from .entity.city import City
21 | from .entity.country import Country
22 | from .entity.region import Region
23 | from .entity.timezone import Timezone
24 | from .repository.city import CityRepository
25 | from .repository.country import CountryRepository
26 | from .repository.region import RegionRepository
27 | from .repository.timezone import TimezoneRepository
28 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/entity/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/entity/city.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class City(object):
25 | id: str
26 | latitude: str
27 | longitude: str
28 | name: str
29 | timezone: str
30 |
31 |
32 | @dataclass
33 | class GeographicLocation(object):
34 | city: str
35 | country: str
36 | region: str
37 | latitude: str
38 | longitude: str
39 | timezone: str
40 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/entity/country.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class Country(object):
25 | id: str
26 | iso_code: str
27 | name: str
28 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/entity/region.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class Region(object):
25 | id: str
26 | region_code: str
27 | name: str
28 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/entity/timezone.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from decimal import Decimal
22 |
23 |
24 | @dataclass
25 | class Timezone(object):
26 | id: str
27 | dst_offset: Decimal
28 | gmt_offset: Decimal
29 | name: str
30 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/country.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from ..entity.country import Country
21 | from ...repository_base import RepositoryBase
22 |
23 |
24 | class CountryRepository(RepositoryBase):
25 | def __init__(self, db):
26 | super(CountryRepository, self).__init__(db, __file__)
27 |
28 | def get_countries(self):
29 | db_request = self._build_db_request(sql_file_name="get_countries.sql")
30 | db_result = self.cursor.select_all(db_request)
31 |
32 | return [Country(**row) for row in db_result]
33 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/sql/get_biggest_city_in_country.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | cty.latitude,
3 | cty.longitude,
4 | cty.name AS city,
5 | cntry.name AS country,
6 | r.name AS region,
7 | t.name AS timezone
8 | FROM
9 | geography.city cty
10 | INNER JOIN geography.region r ON cty.region_id = r.id
11 | INNER JOIN geography.country cntry ON r.country_id = cntry.id
12 | INNER JOIN geography.timezone t ON cty.timezone_id = t.id
13 | WHERE
14 | lower(cntry.name) = %(country)s
15 | AND cty.population IS NOT NULL
16 | ORDER BY
17 | cty.population DESC
18 | LIMIT
19 | 1
20 |
21 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/sql/get_biggest_city_in_region.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | cty.latitude,
3 | cty.longitude,
4 | cty.name AS city,
5 | cntry.name AS country,
6 | r.name AS region,
7 | t.name AS timezone
8 | FROM
9 | geography.city cty
10 | INNER JOIN geography.region r ON cty.region_id = r.id
11 | INNER JOIN geography.country cntry ON r.country_id = cntry.id
12 | INNER JOIN geography.timezone t ON cty.timezone_id = t.id
13 | WHERE
14 | lower(r.name) = %(region)s
15 | AND cty.population IS NOT NULL
16 | ORDER BY
17 | cty.population DESC
18 | LIMIT
19 | 1
20 |
21 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/sql/get_cities_by_region.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | c.id,
3 | c.name,
4 | c.latitude,
5 | c.longitude,
6 | t.name as timezone
7 | FROM
8 | geography.city c
9 | INNER JOIN geography.timezone t ON c.timezone_id = t.id
10 | WHERE
11 | region_id = %(region_id)s
12 | ORDER BY
13 | c.name
14 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/sql/get_countries.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | iso_code,
4 | name
5 | FROM
6 | geography.country
7 | ORDER BY
8 | name
9 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/sql/get_geographic_location_by_city.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | cty.latitude,
3 | cty.longitude,
4 | cty.name AS city,
5 | cntry.name AS country,
6 | r.name AS region,
7 | t.name AS timezone
8 | FROM
9 | geography.city cty
10 | INNER JOIN geography.region r ON cty.region_id = r.id
11 | INNER JOIN geography.country cntry ON r.country_id = cntry.id
12 | INNER JOIN geography.timezone t ON cty.timezone_id = t.id
13 | WHERE
14 | lower(cty.name) IN %(possible_city_names)s
15 | ORDER BY
16 | cty.population DESC
17 |
18 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/sql/get_regions_by_country.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | region_code,
4 | name
5 | FROM
6 | geography.region
7 | WHERE
8 | country_id = %(country_id)s
9 | ORDER BY
10 | name
11 |
--------------------------------------------------------------------------------
/shared/selene/data/geography/repository/sql/get_timezones_by_country.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | name,
4 | gmt_offset,
5 | dst_offset
6 | FROM
7 | geography.timezone
8 | WHERE
9 | country_id = %(country_id)s
10 | ORDER BY
11 | name
12 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Public API for the selene.data.metric package."""
20 |
21 | from .entity.api import ApiMetric
22 | from .entity.core import CoreMetric, CoreInteraction
23 | from .entity.job import JobMetric
24 | from .entity.stt import SttTranscriptionMetric
25 | from .repository.account_activity import AccountActivityRepository
26 | from .repository.api import ApiMetricsRepository
27 | from .repository.core import CoreMetricRepository
28 | from .repository.job import JobRepository
29 | from .repository.stt import TranscriptionMetricRepository
30 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/entity/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/entity/api.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from datetime import datetime
22 | from decimal import Decimal
23 |
24 |
25 | @dataclass
26 | class ApiMetric(object):
27 | url: str
28 | access_ts: datetime
29 | api: str
30 | duration: Decimal
31 | http_method: str
32 | http_status: int
33 | id: str = None
34 | account_id: str = None
35 | device_id: str = None
36 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/entity/job.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from datetime import date, datetime
22 |
23 |
24 | @dataclass
25 | class JobMetric(object):
26 | job_name: str
27 | batch_date: date
28 | start_ts: datetime
29 | end_ts: datetime
30 | command: str
31 | success: bool
32 | id: str = None
33 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/add_account_activity.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | metric.account_activity (
3 | accounts,
4 | members,
5 | open_dataset
6 | )
7 | VALUES
8 | (
9 | (SELECT count(*) FROM account.account),
10 | (
11 | SELECT
12 | count(*)
13 | FROM
14 | account.account_membership
15 | WHERE
16 | membership_ts_range @> current_date::timestamp
17 | ),
18 | (
19 | SELECT
20 | count(aa.*)
21 | FROM
22 | account.account_agreement aa
23 | INNER JOIN account.agreement a ON aa.agreement_id = a.id
24 | WHERE
25 | a.agreement = 'Open Dataset'
26 | )
27 | )
28 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/add_api_metric.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | metric.api (
3 | url,
4 | access_ts,
5 | api,
6 | account_id,
7 | device_id,
8 | duration,
9 | http_method,
10 | http_status
11 | )
12 | VALUES
13 | (
14 | %(url)s,
15 | %(access_ts)s,
16 | %(api)s,
17 | %(account_id)s,
18 | %(device_id)s,
19 | %(duration)s,
20 | %(http_method)s,
21 | %(http_status)s
22 | )
23 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/add_core_interaction.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | metric.core_interaction (
3 | device_id,
4 | core_id,
5 | start_ts,
6 | stt_engine,
7 | stt_transcription,
8 | stt_duration,
9 | intent_type,
10 | intent_duration,
11 | fallback_handler_duration,
12 | skill_handler,
13 | skill_duration,
14 | tts_engine,
15 | tts_utterance,
16 | tts_duration,
17 | speech_playback_duration,
18 | user_latency
19 | )
20 | VALUES
21 | (
22 | %(device_id)s,
23 | %(core_id)s,
24 | %(start_ts)s,
25 | %(stt_engine)s,
26 | %(stt_transcription)s,
27 | %(stt_duration)s,
28 | %(intent_type)s,
29 | %(intent_duration)s,
30 | %(fallback_handler_duration)s,
31 | %(skill_handler)s,
32 | %(skill_duration)s,
33 | %(tts_engine)s,
34 | %(tts_utterance)s,
35 | %(tts_duration)s,
36 | %(speech_playback_duration)s,
37 | %(user_latency)s
38 | )
39 | RETURNING
40 | id
41 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/add_core_metric.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | metric.core (device_id, metric_type, metric_value)
3 | VALUES
4 | (%(device_id)s, %(metric_type)s, %(metric_value)s)
5 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/add_job_metric.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | metric.job
3 | VALUES (
4 | DEFAULT,
5 | %(job_name)s,
6 | %(batch_date)s,
7 | %(start_ts)s,
8 | %(end_ts)s,
9 | %(command)s,
10 | %(success)s
11 | )
12 | RETURNING
13 | id
14 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/add_tts_transcription_metric.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | metric.stt_transcription
3 | VALUES (
4 | DEFAULT,
5 | %(account_id)s,
6 | %(engine)s,
7 | %(success)s,
8 | %(audio_duration)s,
9 | %(transcription_duration)s
10 | )
11 | RETURNING
12 | id
13 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/create_api_metric_partition.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE IF NOT EXISTS
2 | metric.api_history_{partition}
3 | PARTITION OF
4 | metric .api_history
5 | FOR VALUES FROM
6 | (%(start_ts)s) TO (%(end_ts)s)
7 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/create_api_metric_partition_index.sql:
--------------------------------------------------------------------------------
1 | CREATE INDEX IF NOT EXISTS
2 | api_history_{partition}_access_ts_idx
3 | ON
4 | metric.api_history_{partition} (access_ts)
5 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/delete_account_activity_date.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | metric.account_activity
3 | WHERE
4 | activity_dt = %(activity_date)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/delete_api_metrics_by_date.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | metric.api
3 | WHERE
4 | access_ts::date = %(delete_date)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/delete_stt_transcription_by_date.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | metric.stt_transcription
3 | WHERE
4 | insert_ts::date = %(transcription_date)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/get_account_activity_by_date.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | accounts,
3 | accounts_added,
4 | accounts_deleted,
5 | accounts_active,
6 | members,
7 | members_added,
8 | members_expired,
9 | members_active,
10 | open_dataset,
11 | open_dataset_added,
12 | open_dataset_deleted,
13 | open_dataset_active
14 | FROM
15 | metric.account_activity
16 | WHERE
17 | activity_dt = %(activity_date)s
18 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/get_api_metrics_for_date.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | *
3 | FROM
4 | metric.api
5 | WHERE
6 | access_ts::date = %(metrics_date)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/get_core_metric_by_device.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | device_id,
4 | metric_type,
5 | metric_value
6 | FROM
7 | metric.core
8 | WHERE
9 | device_id = %(device_id)s
10 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/get_core_timing_metrics_by_date.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | device_id,
3 | metric_type,
4 | metric_value
5 | FROM
6 | metric.core
7 | WHERE
8 | metric_type = 'timing'
9 | AND metric_value ->> 'id' NOT IN ('unknown', 'null')
10 | AND insert_ts::date = %(metric_date)s
11 | ORDER BY
12 | metric_value ->> 'id',
13 | metric_value ->> 'start_time'
14 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/get_tts_transcription_by_account.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | account_id,
3 | engine,
4 | success,
5 | audio_duration,
6 | transcription_duration
7 | FROM
8 | metric.stt_transcription
9 | WHERE
10 | account_id = %(account_id)s
11 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/increment_accounts_added.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | metric.account_activity
3 | SET
4 | accounts = accounts + 1,
5 | accounts_added = accounts_added + 1
6 | WHERE
7 | activity_dt = current_date
8 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/increment_accounts_deleted.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | metric.account_activity
3 | SET
4 | accounts = accounts - 1,
5 | accounts_deleted = accounts_deleted + 1
6 | WHERE
7 | activity_dt = current_date
8 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/increment_activity.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | metric.account_activity
3 | SET
4 | accounts_active = accounts_active + 1,
5 | members_active = members_active + %(member_increment)s,
6 | open_dataset_active = open_dataset_active + %(open_dataset_increment)s
7 | WHERE
8 | activity_dt = current_date
9 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/increment_members_added.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | metric.account_activity
3 | SET
4 | members = members + 1,
5 | members_added = members_added + 1
6 | WHERE
7 | activity_dt = current_date
8 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/increment_members_expired.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | metric.account_activity
3 | SET
4 | members = members - 1,
5 | members_expired = members_expired + 1
6 | WHERE
7 | activity_dt = current_date
8 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/increment_open_dataset_added.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | metric.account_activity
3 | SET
4 | open_dataset = open_dataset + 1,
5 | open_dataset_added = open_dataset_added + 1
6 | WHERE
7 | activity_dt = current_date
8 |
--------------------------------------------------------------------------------
/shared/selene/data/metric/repository/sql/increment_open_dataset_deleted.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | metric.account_activity
3 | SET
4 | open_dataset = open_dataset - 1,
5 | open_dataset_deleted = open_dataset_deleted + 1
6 | WHERE
7 | activity_dt = current_date
8 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from .entity.display import SkillDisplay
21 | from .entity.skill import Skill
22 | from .entity.skill_setting import (
23 | AccountSkillSetting,
24 | DeviceSkillSetting,
25 | SettingsDisplay,
26 | )
27 | from .repository.display import SkillDisplayRepository
28 | from .repository.setting import SkillSettingRepository
29 | from .repository.settings_display import SettingsDisplayRepository
30 | from .repository.skill import extract_family_from_global_id, SkillRepository
31 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/entity/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/entity/display.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class SkillDisplay(object):
25 | skill_id: str
26 | core_version: str
27 | display_data: dict
28 | id: str = None
29 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/entity/skill.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from typing import List
22 |
23 |
24 | @dataclass
25 | class SkillVersion(object):
26 | version: str
27 | display_name: str
28 |
29 |
30 | @dataclass
31 | class Skill(object):
32 | skill_gid: str
33 | id: str = None
34 |
35 |
36 | @dataclass
37 | class SkillFamily(object):
38 | display_name: str
39 | family_name: str
40 | has_settings: bool
41 | market_id: str
42 | skill_ids: List[str]
43 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/entity/skill_setting.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 | from typing import List
22 |
23 |
24 | @dataclass
25 | class AccountSkillSetting(object):
26 | settings_definition: dict
27 | settings_values: dict
28 | device_names: List[str]
29 |
30 |
31 | @dataclass
32 | class DeviceSkillSetting(object):
33 | settings_display: dict
34 | settings_values: dict
35 | skill_id: str
36 |
37 |
38 | @dataclass
39 | class SettingsDisplay(object):
40 | skill_id: str
41 | display_data: dict
42 | id: str = None
43 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/add_device_skill.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | device.device_skill (device_id, skill_id, skill_settings_display_id, settings)
3 | VALUES
4 | (%(device_id)s, %(skill_id)s, %(skill_settings_display_id)s, %(settings_value)s)
5 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/add_settings_display.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | skill.settings_display (skill_id, settings_display)
3 | VALUES
4 | (%(skill_id)s, %(display_data)s)
5 | RETURNING
6 | id
7 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/add_skill.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | skill.skill (skill_gid, family_name)
3 | VALUES
4 | (%(skill_gid)s, %(family_name)s)
5 | RETURNING
6 | id
7 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/delete_device_skill.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | device.device_skill
3 | WHERE
4 | id = (
5 | SELECT
6 | ds.id
7 | FROM
8 | device.device_skill ds
9 | INNER JOIN
10 | skill.skill s ON ds.skill_id = s.id
11 | WHERE
12 | ds.device_id = %(device_id)s AND s.skill_gid = %(skill_gid)s
13 | )
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/delete_settings_display.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | skill.settings_display
3 | WHERE
4 | id = %(settings_display_id)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/get_display_data_for_skill.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | skill_id,
4 | core_version,
5 | display_data
6 | FROM
7 | skill.display
8 | WHERE
9 | id = %(skill_display_id)s
10 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/get_display_data_for_skills.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | skill_id,
4 | core_version,
5 | display_data
6 | FROM
7 | skill.display
8 | WHERE
9 | core_version = %(core_version)s
10 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/get_settings_definition_by_gid.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | sd.id,
3 | sd.skill_id,
4 | sd.settings_display as display_data
5 | FROM
6 | skill.settings_display sd
7 | INNER JOIN skill.skill s ON sd.skill_id = s.id
8 | WHERE
9 | s.skill_gid = %(global_id)s
10 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/get_settings_display_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id
3 | FROM
4 | skill.settings_display
5 | WHERE
6 | skill_id = %(skill_id)s
7 | AND settings_display = %(display_data)s
8 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/get_settings_for_skill_family.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | sd.settings_display::jsonb -> 'skillMetadata' AS settings_definition,
3 | ds.settings::jsonb AS settings_values,
4 | array_agg(d.name) AS device_names
5 | FROM
6 | device.device_skill ds
7 | INNER JOIN device.device d ON ds.device_id = d.id
8 | INNER JOIN skill.skill s ON ds.skill_id = s.id
9 | LEFT JOIN skill.settings_display sd ON ds.skill_settings_display_id = sd.id
10 | WHERE
11 | s.family_name = %(family_name)s
12 | AND d.account_id = %(account_id)s
13 | GROUP BY
14 | settings_definition,
15 | settings_values
16 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/get_skill_by_global_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id,
3 | skill_gid
4 | FROM
5 | skill.skill
6 | WHERE
7 | skill_gid = %(skill_global_id)s;
8 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/get_skill_setting_by_device.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | dds.skill_id,
3 | dds.settings AS settings_values,
4 | ssd.settings_display
5 | FROM
6 | device.device_skill dds
7 | INNER JOIN skill.skill ss ON dds.skill_id = ss.id
8 | INNER JOIN skill.settings_display ssd ON dds.skill_settings_display_id = ssd.id
9 | WHERE
10 | dds.device_id = %(device_id)s
11 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/get_skills_for_account.sql:
--------------------------------------------------------------------------------
1 | SELECT DISTINCT
2 | ss.family_name,
3 | sd.id AS market_id,
4 | ssd.settings_display -> 'skillMetadata' IS NOT NULL AS has_settings,
5 | ssd.settings_display -> 'display_name' AS display_name,
6 | array_agg(DISTINCT ss.id::text) AS skill_ids
7 | FROM
8 | skill.skill ss
9 | INNER JOIN device.device_skill dds ON dds.skill_id = ss.id
10 | INNER JOIN device.device dd ON dd.id = dds.device_id
11 | LEFT JOIN skill.display sd ON ss.id = sd.skill_id
12 | LEFT JOIN skill.settings_display ssd ON ssd.skill_id = ss.id
13 | WHERE
14 | ssd.id = dds.skill_settings_display_id
15 | AND dd.account_id = %(account_id)s
16 | GROUP BY
17 | 1, 2, 3, 4
18 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/remove_skill_by_gid.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | skill.skill
3 | WHERE
4 | skill_gid = %(skill_gid)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/update_device_skill_settings.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | device.device_skill
3 | SET
4 | settings = %(settings_values)s
5 | WHERE
6 | skill_id IN %(skill_id)s
7 | AND device_id IN (
8 | SELECT
9 | id
10 | FROM
11 | device.device
12 | WHERE
13 | account_id = %(account_id)s
14 | AND name IN %(device_names)s
15 | )
16 |
--------------------------------------------------------------------------------
/shared/selene/data/skill/repository/sql/upsert_skill_display_data.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | skill.display (skill_id, core_version, display_data)
3 | VALUES
4 | (
5 | %(skill_id)s,
6 | %(core_version)s,
7 | %(display_data)s
8 | )
9 | ON CONFLICT
10 | (skill_id, core_version)
11 | DO UPDATE SET
12 | display_data = %(display_data)s
13 | RETURNING
14 | id
15 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/entity/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/entity/file_designation.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Data entities representing a designation applied to a wake word file."""
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class FileDesignation:
25 | """Representation a designation applied to a wake word file."""
26 |
27 | file_id: str
28 | tag_id: str
29 | tag_value_id: str
30 | id: str = None
31 | file_name: str = None
32 | file_directory: str = None
33 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/entity/file_location.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Data entities representing possible locations of machine learning training files."""
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class TaggingFileLocation:
25 | """Data representation of a directory containing machine learning training files."""
26 |
27 | server: str
28 | directory: str
29 | id: str = None
30 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/entity/file_tag.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Data entities representing a tag applied to a wake word file."""
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class FileTag:
25 | """Representation a tag applied to a wake word file and its possible values."""
26 |
27 | file_id: str
28 | session_id: str
29 | tag_id: str
30 | tag_value_id: str
31 | id: str = None
32 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/entity/tag.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Data entities representing a type of tag used to describe an audio file."""
20 | from dataclasses import dataclass
21 | from typing import List
22 |
23 | from .tag_value import TagValue
24 |
25 |
26 | @dataclass
27 | class Tag:
28 | """Dataclass representation of a tag and its values."""
29 |
30 | id: str
31 | name: str
32 | title: str
33 | instructions: str
34 | priority: str
35 | values: List[TagValue]
36 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/entity/tag_value.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Data entities representing a value of a tag."""
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class TagValue:
25 | """Representation of a value of a tag."""
26 |
27 | value: str
28 | display: str
29 | id: str = None
30 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/entity/tagger.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Data entities representing possible locations of machine learning training files."""
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class Tagger:
25 | """Data representation of a tagging entity."""
26 |
27 | entity_type: str
28 | entity_id: str
29 | id: str = None
30 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/add_file_location.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | tagging.file_location (server, directory)
3 | VALUES
4 | (%(server)s, %(directory)s)
5 | RETURNING
6 | id
7 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/add_session.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | tagging.session (tagger_id, session_ts_range)
3 | VALUES
4 | (%(tagger_id)s, '[now,]'::tsrange)
5 | RETURNING
6 | id
7 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/add_tagger.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | tagging.tagger (entity_type, entity_id)
3 | VALUES
4 | (%(entity_type)s, %(entity_id)s)
5 | RETURNING
6 | id
7 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/add_tagging_session.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | tagging.session (tagger_id)
3 | VALUES
4 | (%(tagger_id)s)
5 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/add_wake_word_file.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | tagging.wake_word_file (
3 | wake_word_id,
4 | name,
5 | origin,
6 | submission_date,
7 | account_id,
8 | file_location_id
9 | )
10 | VALUES
11 | (
12 | %(wake_word_id)s,
13 | %(file_name)s,
14 | %(origin)s,
15 | %(submission_date)s,
16 | %(account_id)s,
17 | %(file_location_id)s
18 | )
19 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/add_wake_word_file_designation.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | tagging.wake_word_file_designation (wake_word_file_id, tag_id, tag_value_id)
3 | VALUES
4 | (%(file_id)s, %(tag_id)s, %(tag_value_id)s)
5 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/add_wake_word_file_tag.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | tagging.wake_word_file_tag (wake_word_file_id, session_id, tag_id, tag_value_id)
3 | VALUES
4 | (%(file_id)s, %(session_id)s, %(tag_id)s, %(tag_value_id)s)
5 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/change_account_file_status.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | tagging.wake_word_file
3 | SET
4 | status = %(status)s
5 | WHERE
6 | account_id = %(account_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/change_file_location.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | tagging.wake_word_file
3 | SET
4 | file_location_id = %(file_location_id)s,
5 | status = 'stored'::tagging_file_status_enum
6 | WHERE
7 | id = %(wake_word_file_id)s
8 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/change_file_status.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | tagging.wake_word_file
3 | SET
4 | status = %(status)s
5 | WHERE
6 | name = %(file_name)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/get_active_session.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | s.id,
3 | max(ft.insert_ts) AS last_tag_ts
4 | FROM
5 | tagging.session s
6 | LEFT JOIN tagging.wake_word_file_tag ft ON s.id = ft.session_id
7 | WHERE
8 | tagger_id = (
9 | SELECT
10 | id::text
11 | FROM
12 | tagging.tagger
13 | WHERE
14 | entity_type = 'account'
15 | AND entity_id = %(entity_id)s
16 | )
17 | AND upper(session_ts_range) IS NULL
18 | GROUP BY
19 | 1
20 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/get_designation_candidates.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | ww.name AS wake_word,
3 | wwft.wake_word_file_id,
4 | wwft.session_id,
5 | wwft.tag_id,
6 | wwft.tag_value_id
7 | FROM
8 | tagging.wake_word_file wwf
9 | INNER JOIN wake_word.wake_word ww ON wwf.wake_word_id = ww.id
10 | INNER JOIN tagging.wake_word_file_tag wwft ON wwf.id = wwft.wake_word_file_id
11 | LEFT JOIN tagging.wake_word_file_designation wwfd ON wwf.id = wwfd.wake_word_file_id AND wwft.tag_id = wwfd.tag_id
12 | WHERE
13 | wwfd.id IS NULL
14 | ORDER BY
15 | ww.name,
16 | wwft.wake_word_file_id,
17 | wwft.tag_id,
18 | wwft.tag_value_id
19 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/get_designations_from_date.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | wwf.id AS file_id,
3 | wwf.name AS file_name,
4 | fl.directory AS file_directory,
5 | wwfd.tag_id,
6 | wwfd.tag_value_id
7 | FROM
8 | tagging.wake_word_file_designation wwfd
9 | INNER JOIN tagging.wake_word_file wwf ON wwf.id = wwfd.wake_word_file_id
10 | INNER JOIN tagging.file_location fl on fl.id = wwf.file_location_id
11 | WHERE
12 | wwfd.insert_ts::date >= %(start_date)s
13 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/get_file_location_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id
3 | FROM
4 | tagging.file_location
5 | WHERE
6 | server = %(server)s
7 | AND directory = %(directory)s
8 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/get_tagger_by_entity.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id
3 | FROM
4 | tagging.tagger
5 | WHERE
6 | entity_type = %(entity_type)s
7 | AND entity_id = %(entity_id)s
8 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/get_tags.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | t.id,
3 | t.name,
4 | t.title,
5 | t.instructions,
6 | t.priority,
7 | json_agg(
8 | json_build_object(
9 | 'value', tv.value,
10 | 'display', tv.display,
11 | 'id', tv.id
12 | )
13 | ) AS values
14 | FROM
15 | tagging.tag t
16 | LEFT JOIN tagging.tag_value tv ON t.id = tv.tag_id
17 | GROUP BY
18 | t.id,
19 | t.name,
20 | t.title,
21 | t.instructions,
22 | t.priority
23 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/get_wake_word_files.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | json_build_object(
3 | 'name', ww.name,
4 | 'engine', ww.engine,
5 | 'id', ww.id
6 | ) AS wake_word,
7 | wwf.name,
8 | wwf.origin,
9 | wwf.submission_date,
10 | wwf.account_id,
11 | wwf.status,
12 | wwf.id,
13 | json_build_object(
14 | 'server', fl.server,
15 | 'directory', fl.directory,
16 | 'id', ww.id
17 | ) AS location
18 | FROM
19 | tagging.wake_word_file wwf
20 | INNER JOIN tagging.file_location fl ON fl.id = wwf.file_location_id
21 | INNER JOIN wake_word.wake_word ww on ww.id = wwf.wake_word_id
22 | WHERE
23 | {where_clause}
24 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/remove_file_location.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | tagging.file_location
3 | WHERE
4 | id = %(id)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/remove_wake_word_file.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | tagging.wake_word_file
3 | WHERE
4 | id = %(id)s
5 |
--------------------------------------------------------------------------------
/shared/selene/data/tagging/repository/sql/update_session_end_ts.sql:
--------------------------------------------------------------------------------
1 | UPDATE
2 | tagging.session
3 | SET
4 | session_ts_range = tsrange(lower(session_ts_range), %(end_ts)s)
5 | WHERE
6 | id = %(session_id)s
7 |
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from .entity.wake_word import WakeWord
21 | from .entity.pocketsphinx_settings import PocketsphinxSettings
22 | from .repository.wake_word import WakeWordRepository
23 |
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/entity/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MycroftAI/selene-backend/e10ac91cde6bf6097ae7eafe3fcb6c1b1d292f70/shared/selene/data/wake_word/entity/__init__.py
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/entity/pocketsphinx_settings.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class PocketsphinxSettings(object):
25 | id: str
26 | sample_rate: int
27 | channels: int
28 | pronunciation: str
29 | threshold: str
30 | threshold_multiplier: float
31 | dynamic_energy_ratio: float
32 | account_id: str = None
33 |
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/entity/wake_word.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from dataclasses import dataclass
21 |
22 |
23 | @dataclass
24 | class WakeWord(object):
25 | name: str
26 | engine: str
27 | id: str = None
28 |
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/repository/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MycroftAI/selene-backend/e10ac91cde6bf6097ae7eafe3fcb6c1b1d292f70/shared/selene/data/wake_word/repository/__init__.py
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/repository/sql/add_wake_word.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO
2 | wake_word.wake_word (name, engine)
3 | VALUES
4 | (%(name)s, %(engine)s)
5 | RETURNING id
6 |
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/repository/sql/get_wake_word_id.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | id
3 | FROM
4 | wake_word.wake_word
5 | WHERE
6 | name = %(name)s
7 | AND engine = %(engine)s
8 |
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/repository/sql/get_wake_words_for_web.sql:
--------------------------------------------------------------------------------
1 | SELECT
2 | ww.id,
3 | ww.name,
4 | ww.engine
5 | FROM
6 | wake_word.wake_word ww
7 | INNER JOIN wake_word.pocketsphinx_settings ps ON ww.id = ps.wake_word_id
8 | WHERE
9 | ps.account_id is NULL
10 |
--------------------------------------------------------------------------------
/shared/selene/data/wake_word/repository/sql/remove_wake_word.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM
2 | wake_word.wake_word
3 | WHERE
4 | id = %(wake_word_id)s
5 |
--------------------------------------------------------------------------------
/shared/selene/testing/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/testing/account_preference.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from selene.data.device import AccountPreferences, PreferenceRepository
21 |
22 |
23 | def add_account_preference(db, account_id):
24 | account_preferences = AccountPreferences(
25 | date_format="MM/DD/YYYY", time_format="12 Hour", measurement_system="Imperial"
26 | )
27 | preference_repo = PreferenceRepository(db, account_id)
28 | preference_repo.upsert(account_preferences)
29 |
--------------------------------------------------------------------------------
/shared/selene/util/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
--------------------------------------------------------------------------------
/shared/selene/util/db/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from .connection import connect_to_db, DatabaseConnectionConfig
21 | from .connection_pool import (
22 | allocate_db_connection_pool,
23 | get_db_connection,
24 | get_db_connection_from_pool,
25 | return_db_connection_to_pool,
26 | )
27 | from .cursor import Cursor, DatabaseRequest, DatabaseBatchRequest, get_sql_from_file
28 | from .transaction import use_transaction
29 |
--------------------------------------------------------------------------------
/shared/selene/util/email/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Public API into the selene.util.email package."""
20 |
21 | from .email import EmailMessage, SeleneMailer, validate_email_address
22 |
--------------------------------------------------------------------------------
/shared/selene/util/email/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |

7 |
16 |
17 |
Greetings,
18 | {% block email_body %}
19 | {% endblock email_body %}
20 |
Regards,
21 |
The Mycroft AI Team
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/shared/selene/util/email/templates/email_change.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block email_body %}
3 |
4 | A change to the email address associated with your Mycroft account has been requested. If you did not make
5 | this request, please contact us immediately at support@mycroft.ai. Otherwise, check the inbox for the new email
6 | address for verification instructions. If you don't see the verification email in your inbox, please check your
7 | spam folder.
8 |
9 | Your account will not be updated until the new email address is verified.
10 |
11 | {% endblock email_body %}
12 |
--------------------------------------------------------------------------------
/shared/selene/util/email/templates/email_verification.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block email_body %}
3 |
4 | A change to the email address associated with your Mycroft account has been requested. Before this change can
5 | be applied, the new email address must be verified.
6 |
7 | To verify this email address, click the button below.
8 |
21 | VERIFY EMAIL ADDRESS
22 |
23 | {% endblock email_body %}
24 |
--------------------------------------------------------------------------------
/shared/selene/util/email/templates/password_change.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block email_body %}
3 |
4 | The password for the Mycroft account associated with this email address has been changed. If you
5 | did not update your password, please contact us immediately at support@mycroft.ai. Otherwise, you can
6 | ignore this message.
7 |
8 | {% endblock email_body %}
9 |
--------------------------------------------------------------------------------
/shared/selene/util/email/templates/reset_password.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block email_body %}
3 |
4 | A password reset was requested for the Mycroft account associated with this email address. If you did
5 | not make this request, you can ignore this message.
6 |
7 | To reset your password, click the button below.
8 |
21 | RESET PASSWORD
22 |
23 | {% endblock email_body %}
24 |
--------------------------------------------------------------------------------
/shared/selene/util/exceptions.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | """Define custom exceptions used in Selene APIs and scripts"""
21 |
22 |
23 | class NotModifiedException(Exception):
24 | """Raise this exception when a request contains an etag found in cache.
25 |
26 | The Flask blueprint will catch this exception and return a HTTP 304 code.
27 | """
28 |
29 | pass
30 |
--------------------------------------------------------------------------------
/shared/selene/util/payment/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2019 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 |
20 | from .stripe import (
21 | cancel_stripe_subscription,
22 | create_stripe_account,
23 | create_stripe_subscription,
24 | )
25 |
--------------------------------------------------------------------------------
/shared/selene/util/ssh/__init__.py:
--------------------------------------------------------------------------------
1 | # Mycroft Server - Backend
2 | # Copyright (C) 2020 Mycroft AI Inc
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 | #
5 | # This file is part of the Mycroft Server.
6 | #
7 | # The Mycroft Server is free software: you can redistribute it and/or
8 | # modify it under the terms of the GNU Affero General Public License as
9 | # published by the Free Software Foundation, either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU Affero General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Affero General Public License
18 | # along with this program. If not, see .
19 | """Public API into the ssh package."""
20 | from .sftp import get_remote_file
21 | from .ssh import SshClientConfig, validate_rsa_public_key
22 |
--------------------------------------------------------------------------------