tweak AsyncSnapd api slightly
also remove dry-run delay for requests to /v2/change/{id}
This commit is contained in:
parent
97c276faca
commit
521e7026de
|
@ -213,9 +213,9 @@ class RefreshController(SubiquityController):
|
||||||
|
|
||||||
@with_context()
|
@with_context()
|
||||||
async def start_update(self, context):
|
async def start_update(self, context):
|
||||||
change = await self.app.snapd.post(
|
change = (await self.app.snapd.post(
|
||||||
'v2/snaps/{}'.format(self.snap_name),
|
'v2/snaps/{}'.format(self.snap_name),
|
||||||
{'action': 'refresh', 'ignore-running': True})
|
{'action': 'refresh', 'ignore-running': True}))['change']
|
||||||
context.description = "change id: {}".format(change)
|
context.description = "change id: {}".format(change)
|
||||||
return change
|
return change
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,7 @@ class FakeSnapdConnection:
|
||||||
"Don't know how to fake POST response to {}".format((path, args)))
|
"Don't know how to fake POST response to {}".format((path, args)))
|
||||||
|
|
||||||
def get(self, path, **args):
|
def get(self, path, **args):
|
||||||
|
if 'change' not in path:
|
||||||
time.sleep(1/self.scale_factor)
|
time.sleep(1/self.scale_factor)
|
||||||
filename = path.replace('/', '-')
|
filename = path.replace('/', '-')
|
||||||
if args:
|
if args:
|
||||||
|
@ -184,10 +185,10 @@ class AsyncSnapd:
|
||||||
response = await run_in_thread(
|
response = await run_in_thread(
|
||||||
partial(self.connection.post, path, body, **args))
|
partial(self.connection.post, path, body, **args))
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()['change']
|
return response.json()
|
||||||
|
|
||||||
async def post_and_wait(self, path, body, **args):
|
async def post_and_wait(self, path, body, **args):
|
||||||
change = await self.post(path, body, **args)
|
change = (await self.post(path, body, **args))['change']
|
||||||
change_path = 'v2/changes/{}'.format(change)
|
change_path = 'v2/changes/{}'.format(change)
|
||||||
while True:
|
while True:
|
||||||
result = await self.get(change_path)
|
result = await self.get(change_path)
|
||||||
|
|
Loading…
Reference in New Issue