44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime
|
|
from typing import Dict
|
|
|
|
|
|
@dataclass
|
|
class VersionReport:
|
|
core: str
|
|
commit: str
|
|
short_commit: str
|
|
branch: str
|
|
remote: str
|
|
channel: str
|
|
build: int
|
|
date: datetime
|
|
dirty: bool
|
|
modules: Dict[str, str] = field(default_factory=dict)
|
|
plugins: Dict[str, str] = field(default_factory=dict)
|
|
|
|
|
|
class VersionManager:
|
|
def __init__(self, app: "OverUB") -> None:
|
|
self.app = app
|
|
|
|
async def get_report(self) -> VersionReport:
|
|
info = await self.app.updater.get_version_info()
|
|
modules = {name: mod.version for name, mod in self.app.modules._loaded.items()}
|
|
plugins = {name: plugin.version for name, plugin in self.app.plugins._loaded.items()}
|
|
return VersionReport(
|
|
core=info.core,
|
|
commit=info.commit,
|
|
short_commit=info.short_commit,
|
|
branch=info.branch,
|
|
remote=info.remote,
|
|
channel=info.channel,
|
|
build=0,
|
|
date=info.date,
|
|
dirty=info.dirty,
|
|
modules=modules,
|
|
plugins=plugins,
|
|
)
|