Models#

Referential#

These models represent the fixed reference data that packages are built against.

class spkrepo.models.Architecture(**kwargs)[source]#

A supported NAS CPU architecture (e.g. x86_64, apollolake) that a build can target.

builds#
code#
download_count#
classmethod find(code, syno=False)[source]#

Look up an architecture by its code, or return None if not found. If syno=True, code is first translated from its Synology DSM/SRM spelling (e.g. “88f6281”) to its canonical form.

from_syno = {'88f6281': '88f628x', '88f6282': '88f628x'}#
id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

recent_download_count#
recent_target_download_count#
target_download_count#
to_syno = {'88f628x': '88f6281'}#
class spkrepo.models.Firmware(**kwargs)[source]#

A specific DSM/SRM firmware release, identified by its build number, used to define a build’s supported firmware range.

build#
download_count#
classmethod find(build)[source]#

Look up a firmware by its build number, or return None if not found.

property firmware_string#

Combined “version-build” string, e.g. “7.2-64570”.

id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

recent_download_count#
recent_target_download_count#
target_download_count#
type#
version#
class spkrepo.models.Language(**kwargs)[source]#

A supported language/locale code (e.g. enu, chs) used for version display names and build descriptions.

code#
classmethod find(code)[source]#

Look up a language by its code, or return None if not found.

id#
name#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

class spkrepo.models.Service(**kwargs)[source]#

A named system service that a version can declare as an install-time dependency (INFO’s install_dep_services).

code#
classmethod find(code)[source]#

Look up a service by its code, or return None if not found.

id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

Users#

class spkrepo.models.User(**kwargs)[source]#

A registered user, including authentication credentials and their authored/maintained package relationships.

active: bool#
api_key#
authored_packages#
confirmed_at: datetime | None#
email: str#
fs_uniquifier: str#
github_access_token#
id: int#
maintained_packages#
password: str | None#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

roles: list[RoleMixin]#
username: str | None#
class spkrepo.models.Role(**kwargs)[source]#

A named permission role (e.g. admin, developer, package_admin) assignable to users.

description: str | None#
classmethod find(name)[source]#

Look up a role by its name, or return None if not found.

id: int#
name: str#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

users#

Core#

The three-level hierarchy that represents a package in the repository: a Package has one or more Version records, each of which has one or more Build records per architecture/firmware combination.

class spkrepo.models.Package(**kwargs)[source]#

A SynoCommunity package, grouping all of its released Versions.

author#
author_user_id#
download_count#
download_counts#
download_stats#
classmethod find(name)[source]#

Look up a package by its name, or return None if not found.

has_active_builds#
id#
insert_date#
last_download_date#
maintainers#
name#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

recent_download_count#
screenshots#
versions#
class spkrepo.models.Version(**kwargs)[source]#

A single released version of a package, grouping one or more architecture/firmware-specific Builds.

all_builds_active#

True if every build of this version is marked active.

all_builds_uploaded#

True if every build of this version has been uploaded to remote storage.

beta#

True if this version has a report_url set, marking it as a beta/testing release.

builds#
property builds_per_dsm#

Group builds by DSM/SRM major version, newest-first, with each group’s builds also ordered by full firmware version, newest-first, so e.g. 7.2.x builds don’t interleave with 7.1.x builds.

displaynames#
distributor#
distributor_url#
download_count#
icons#
id#
insert_date#
install_wizard#
license#
maintainer#
maintainer_url#
package#
package_id#
property path#

This version’s directory path on disk, relative to DATA_PATH.

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

recent_download_count#
report_url#
service_dependencies#
startable#
total_size#

Combined file size in bytes across all builds with a known size, or None if no build has one.

upgrade_wizard#
upstream_version#
version#
property version_string#

Combined “upstream_version-version” string, e.g. “1.4.103-10”.

class spkrepo.models.Build(**kwargs)[source]#

A single compiled package artifact for one Version, targeting a specific firmware range and set of architectures.

active#
architectures#
buildmanifest#
calculate_md5()[source]#

Compute and return this build’s file’s MD5 checksum by reading it from disk in chunks.

calculate_size()[source]#

Return this build’s file size in bytes, read from disk.

changelog#
checksum#
descriptions#
download_stats#
firmware_max#
firmware_max_id#
firmware_min#
firmware_min_id#
classmethod generate_filename(package, version, firmware, architectures)[source]#

Build a Build’s .spk filename from its constituent parts.

Takes package/version/firmware/architectures explicitly, rather than reading them off an instance, because callers need the filename to construct Build.path before the Build itself exists (see api.py’s upload handler). Pass the intended firmware (typically firmware_min).

id#
insert_date#
md5#
path#
publisher#
publisher_user_id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

save(stream)[source]#

Write the given binary stream to this build’s file on disk at self.path.

signed#
size#
storage#
version#
version_id#

Data#

Supporting data attached to packages and builds.

class spkrepo.models.Screenshot(**kwargs)[source]#

A package screenshot image, stored on disk under DATA_PATH.

id#
package#
package_id#
path#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

save(stream)[source]#

Write the given binary stream to this screenshot’s file on disk at self.path.

class spkrepo.models.DisplayName(**kwargs)[source]#

A version’s localized display name for a single language.

displayname#
language#
language_id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

version_id#
class spkrepo.models.BuildDescription(**kwargs)[source]#

A build’s localized description text for a single language.

build_id#
description#
language#
language_id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

class spkrepo.models.BuildManifest(**kwargs)[source]#

A build’s install-time dependency/conflict/permission manifest, parsed from its SPK INFO/conf files.

build#
build_id#
conf_conflicts#
conf_dependencies#
conf_privilege#
conf_resource#
conflicts#
dependencies#
id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

class spkrepo.models.Icon(**kwargs)[source]#

A package icon image at a specific size (72/120/256px), stored on disk under DATA_PATH.

id#
path#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

save(stream)[source]#

Write the given binary stream to this icon’s file on disk at self.path.

size#
version#
version_id#

Statistics#

class spkrepo.models.DownloadStat(**kwargs)[source]#

A single day’s download count for a package, optionally broken down by build, architecture, and/or firmware. Aggregated into PackageDownloadCounts via a materialized view refresh.

architecture#
architecture_id#
build#
build_id#
count#
date#
download_source#
firmware_build#
id#
package#
package_id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

target_firmware_build#
target_noarch#
class spkrepo.models.PackageDownloadCounts(**kwargs)[source]#

Read-only model backed by the package_download_counts materialized view.

Refreshed after each ingest_logs run via REFRESH MATERIALIZED VIEW CONCURRENTLY. Never written to directly.

download_count#
package_id#
query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

recent_download_count#

Exceptions#

Exceptions raised by the spkrepo application layer.

class spkrepo.exceptions.SpkrepoError[source]#

Base class for exceptions in spkrepo

class spkrepo.exceptions.SPKParseError[source]#

Exception raised when SPK parsing fails

class spkrepo.exceptions.SPKSignError[source]#

Exception raised when SPK signing fails