summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-06-09 00:38:32 +0300
committerDevaev Maxim <[email protected]>2020-06-09 00:38:32 +0300
commit9a4eb3717f6140c56134ce064ca99f38ced30159 (patch)
tree5317b1fd7fe0beeaf2949b3ec523f25baf27b60d /kvmd
parent340b879e2353a3d8f05c73914a83a39e7b0278b1 (diff)
move to 0x0, refactoring
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/kvmd/snapshoter.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/kvmd/apps/kvmd/snapshoter.py b/kvmd/apps/kvmd/snapshoter.py
index 82ae8815..d0580861 100644
--- a/kvmd/apps/kvmd/snapshoter.py
+++ b/kvmd/apps/kvmd/snapshoter.py
@@ -99,20 +99,7 @@ class Snapshoter: # pylint: disable=too-many-instance-attributes
await notifier.notify()
if not live:
- if self.__wakeup_key:
- logger.info("Waking up using key %r ...", self.__wakeup_key)
- self.__hid.send_key_events([
- (self.__wakeup_key, True),
- (self.__wakeup_key, False),
- ])
- if self.__wakeup_move:
- logger.info("Waking up using mouse move for %d units ...", self.__wakeup_move)
- self.__hid.send_mouse_move_event(0, 0)
- self.__hid.send_mouse_move_event(self.__wakeup_move, self.__wakeup_move)
-
- if self.__online_delay:
- logger.info("Waiting %.2f seconds for online ...", self.__online_delay)
- await asyncio.sleep(self.__online_delay)
+ await self.__wakeup()
retries = self.__retries
while retries:
@@ -130,3 +117,22 @@ class Snapshoter: # pylint: disable=too-many-instance-attributes
finally:
self.__snapshoting = False
await notifier.notify()
+
+ async def __wakeup(self) -> None:
+ logger = get_logger(0)
+
+ if self.__wakeup_key:
+ logger.info("Waking up using key %r ...", self.__wakeup_key)
+ self.__hid.send_key_events([
+ (self.__wakeup_key, True),
+ (self.__wakeup_key, False),
+ ])
+
+ if self.__wakeup_move:
+ logger.info("Waking up using mouse move for %d units ...", self.__wakeup_move)
+ for (to_x, to_y) in [(0, 0), (self.__wakeup_move, self.__wakeup_move), (0, 0)]:
+ self.__hid.send_mouse_move_event(to_x, to_y)
+
+ if self.__online_delay:
+ logger.info("Waiting %.2f seconds for online ...", self.__online_delay)
+ await asyncio.sleep(self.__online_delay)