moonraker: refactor "make_request"

The make_request() method is now awaitable and returns the result directly vs the previous behavior of returning a request that was awaited.

There is no longer a need to check the result to see if it is an error, exceptions are raised if an error is detected.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine
2020-08-12 08:43:37 -04:00
parent d04a419a80
commit a7147a44ca
7 changed files with 71 additions and 72 deletions

View File

@@ -167,11 +167,8 @@ class FileManager:
async def _handle_operation_check(self, requested_path):
# Get virtual_sdcard status
request = self.server.make_request(
result = await self.server.make_request(
"objects/status", 'GET', {'print_stats': []})
result = await request.wait()
if isinstance(result, self.server.error):
raise result
pstats = result.get('print_stats', {})
loaded_file = pstats.get('filename', "")
state = pstats.get('state', "")