mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-18 06:36:30 +00:00
Remove coroutine from job update (#2264)
This commit is contained in:
parent
4b500ef873
commit
550fca4bcd
@ -27,7 +27,7 @@ class SupervisorJob(CoreSysAttributes):
|
|||||||
"""Return the current stage."""
|
"""Return the current stage."""
|
||||||
return self._stage
|
return self._stage
|
||||||
|
|
||||||
async def update(
|
def update(
|
||||||
self, progress: Optional[int] = None, stage: Optional[str] = None
|
self, progress: Optional[int] = None, stage: Optional[str] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Update the job object."""
|
"""Update the job object."""
|
||||||
|
@ -66,9 +66,7 @@ class StoreManager(CoreSysAttributes):
|
|||||||
# add new repository
|
# add new repository
|
||||||
async def _add_repository(url: str, step: int):
|
async def _add_repository(url: str, step: int):
|
||||||
"""Add a repository."""
|
"""Add a repository."""
|
||||||
await job.update(
|
job.update(progress=job.progress + step, stage=f"Checking {url} started")
|
||||||
progress=job.progress + step, stage=f"Checking {url} started"
|
|
||||||
)
|
|
||||||
repository = Repository(self.coresys, url)
|
repository = Repository(self.coresys, url)
|
||||||
try:
|
try:
|
||||||
await repository.load()
|
await repository.load()
|
||||||
@ -93,7 +91,7 @@ class StoreManager(CoreSysAttributes):
|
|||||||
|
|
||||||
self.repositories[url] = repository
|
self.repositories[url] = repository
|
||||||
|
|
||||||
await job.update(progress=10, stage="Check repositories")
|
job.update(progress=10, stage="Check repositories")
|
||||||
repos = new_rep - old_rep
|
repos = new_rep - old_rep
|
||||||
tasks = [_add_repository(url, 80 / len(repos)) for url in repos]
|
tasks = [_add_repository(url, 80 / len(repos)) for url in repos]
|
||||||
if tasks:
|
if tasks:
|
||||||
@ -105,13 +103,13 @@ class StoreManager(CoreSysAttributes):
|
|||||||
self.sys_config.drop_addon_repository(url)
|
self.sys_config.drop_addon_repository(url)
|
||||||
|
|
||||||
# update data
|
# update data
|
||||||
await job.update(progress=90, stage="Update addons")
|
job.update(progress=90, stage="Update addons")
|
||||||
self.data.update()
|
self.data.update()
|
||||||
|
|
||||||
await job.update(progress=95, stage="Read addons")
|
job.update(progress=95, stage="Read addons")
|
||||||
self._read_addons()
|
self._read_addons()
|
||||||
|
|
||||||
await job.update(progress=100)
|
job.update(progress=100)
|
||||||
|
|
||||||
def _read_addons(self) -> None:
|
def _read_addons(self) -> None:
|
||||||
"""Reload add-ons inside store."""
|
"""Reload add-ons inside store."""
|
||||||
|
@ -26,7 +26,7 @@ async def test_remove_job_with_progress(coresys: CoreSys):
|
|||||||
job = coresys.jobs.get_job(TEST_JOB)
|
job = coresys.jobs.get_job(TEST_JOB)
|
||||||
|
|
||||||
assert job.name in coresys.jobs.jobs
|
assert job.name in coresys.jobs.jobs
|
||||||
await job.update(progress=100)
|
job.update(progress=100)
|
||||||
assert job.name not in coresys.jobs.jobs
|
assert job.name not in coresys.jobs.jobs
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +34,6 @@ async def test_update_job(coresys: CoreSys):
|
|||||||
"""Test updating jobs."""
|
"""Test updating jobs."""
|
||||||
job = coresys.jobs.get_job(TEST_JOB)
|
job = coresys.jobs.get_job(TEST_JOB)
|
||||||
|
|
||||||
await job.update(progress=50, stage="stage")
|
job.update(progress=50, stage="stage")
|
||||||
assert job.progress == 50
|
assert job.progress == 50
|
||||||
assert job.stage == "stage"
|
assert job.stage == "stage"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user