summaryrefslogtreecommitdiff
path: root/kvmd/plugins
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-03-02 01:26:43 +0300
committerDevaev Maxim <[email protected]>2020-03-02 01:26:43 +0300
commit8972357dbc2147c1a02fd3470befd2b4aed9fc05 (patch)
tree63dfcdf09da43327bd48ba641a399d6ded3bb71d /kvmd/plugins
parente855976f05775359b774c3d5d6c3a6f6532efce6 (diff)
changed region methods to async
Diffstat (limited to 'kvmd/plugins')
-rw-r--r--kvmd/plugins/atx/gpio.py4
-rw-r--r--kvmd/plugins/msd/otg/__init__.py4
-rw-r--r--kvmd/plugins/msd/relay.py12
3 files changed, 10 insertions, 10 deletions
diff --git a/kvmd/plugins/atx/gpio.py b/kvmd/plugins/atx/gpio.py
index cca58a18..51b063bc 100644
--- a/kvmd/plugins/atx/gpio.py
+++ b/kvmd/plugins/atx/gpio.py
@@ -162,7 +162,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes
@aiotools.atomic
async def __click(self, name: str, pin: int, delay: float) -> None:
- with self.__region.exit_only_on_exception():
+ async with self.__region.exit_only_on_exception():
await self.__inner_click(name, pin, delay)
@aiotools.tasked
@@ -176,5 +176,5 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes
gpio.write(pin, False)
await asyncio.sleep(1)
finally:
- self.__region.exit()
+ await self.__region.exit()
get_logger(0).info("Clicked ATX button %r", name)
diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py
index 24d666f9..ff5014cb 100644
--- a/kvmd/plugins/msd/otg/__init__.py
+++ b/kvmd/plugins/msd/otg/__init__.py
@@ -114,7 +114,7 @@ class _State:
@contextlib.asynccontextmanager
async def busy(self, check_online: bool=True) -> AsyncGenerator[None, None]:
- with self._region:
+ async with self._region:
async with self._lock:
await self.__notifier.notify()
if check_online:
@@ -304,7 +304,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
@contextlib.asynccontextmanager
async def write_image(self, name: str) -> AsyncGenerator[None, None]:
try:
- with self.__state._region: # pylint: disable=protected-access
+ async with self.__state._region: # pylint: disable=protected-access
try:
async with self.__state._lock: # pylint: disable=protected-access
await self.__state_notifier.notify()
diff --git a/kvmd/plugins/msd/relay.py b/kvmd/plugins/msd/relay.py
index 81456efa..71a76e9c 100644
--- a/kvmd/plugins/msd/relay.py
+++ b/kvmd/plugins/msd/relay.py
@@ -234,7 +234,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
@aiotools.atomic
async def reset(self) -> None:
- with self.__region.exit_only_on_exception():
+ async with self.__region.exit_only_on_exception():
await self.__inner_reset()
@aiotools.tasked
@@ -254,7 +254,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
try:
gpio.write(self.__reset_pin, False)
finally:
- self.__region.exit()
+ await self.__region.exit()
await self.__state_queue.put(await self.get_state())
@aiotools.atomic
@@ -277,7 +277,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
async with self.__working():
notify = False
try:
- with self.__region:
+ async with self.__region:
if self.__connected:
raise MsdConnectedError()
notify = True
@@ -294,7 +294,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
async with self.__working():
notify = False
try:
- with self.__region:
+ async with self.__region:
if not self.__connected:
raise MsdDisconnectedError()
notify = True
@@ -315,7 +315,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
@contextlib.asynccontextmanager
async def write_image(self, name: str) -> AsyncGenerator[None, None]:
async with self.__working():
- self.__region.enter()
+ await self.__region.enter()
try:
assert self.__device_info
if self.__connected:
@@ -333,7 +333,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
await self.__close_device_file()
await self.__load_device_info()
finally:
- self.__region.exit()
+ await self.__region.exit()
await self.__state_queue.put(await self.get_state())
async def write_image_chunk(self, chunk: bytes) -> int: