mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-17 14:16:29 +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 self._stage
|
||||
|
||||
async def update(
|
||||
def update(
|
||||
self, progress: Optional[int] = None, stage: Optional[str] = None
|
||||
) -> None:
|
||||
"""Update the job object."""
|
||||
|
@ -66,9 +66,7 @@ class StoreManager(CoreSysAttributes):
|
||||
# add new repository
|
||||
async def _add_repository(url: str, step: int):
|
||||
"""Add a repository."""
|
||||
await job.update(
|
||||
progress=job.progress + step, stage=f"Checking {url} started"
|
||||
)
|
||||
job.update(progress=job.progress + step, stage=f"Checking {url} started")
|
||||
repository = Repository(self.coresys, url)
|
||||
try:
|
||||
await repository.load()
|
||||
@ -93,7 +91,7 @@ class StoreManager(CoreSysAttributes):
|
||||
|
||||
self.repositories[url] = repository
|
||||
|
||||
await job.update(progress=10, stage="Check repositories")
|
||||
job.update(progress=10, stage="Check repositories")
|
||||
repos = new_rep - old_rep
|
||||
tasks = [_add_repository(url, 80 / len(repos)) for url in repos]
|
||||
if tasks:
|
||||
@ -105,13 +103,13 @@ class StoreManager(CoreSysAttributes):
|
||||
self.sys_config.drop_addon_repository(url)
|
||||
|
||||
# update data
|
||||
await job.update(progress=90, stage="Update addons")
|
||||
job.update(progress=90, stage="Update addons")
|
||||
self.data.update()
|
||||
|
||||
await job.update(progress=95, stage="Read addons")
|
||||
job.update(progress=95, stage="Read addons")
|
||||
self._read_addons()
|
||||
|
||||
await job.update(progress=100)
|
||||
job.update(progress=100)
|
||||
|
||||
def _read_addons(self) -> None:
|
||||
"""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)
|
||||
|
||||
assert job.name in coresys.jobs.jobs
|
||||
await job.update(progress=100)
|
||||
job.update(progress=100)
|
||||
assert job.name not in coresys.jobs.jobs
|
||||
|
||||
|
||||
@ -34,6 +34,6 @@ async def test_update_job(coresys: CoreSys):
|
||||
"""Test updating jobs."""
|
||||
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.stage == "stage"
|
||||
|
Loading…
x
Reference in New Issue
Block a user