summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-06-08 04:56:37 +0300
committerDevaev Maxim <[email protected]>2020-06-08 04:56:37 +0300
commitf3a9ae75f9b8dfbfd2117e5f55fb6379f5d31e61 (patch)
tree43b6bd76aa592f5e37e63735b738487b6d46de82 /kvmd
parent241c787e105abaa0ec8201e3dcaf42dbad4674cd (diff)
refactoring
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/kvmd/api/streamer.py4
-rw-r--r--kvmd/apps/kvmd/snapshoter.py12
-rw-r--r--kvmd/apps/kvmd/streamer.py4
3 files changed, 10 insertions, 10 deletions
diff --git a/kvmd/apps/kvmd/api/streamer.py b/kvmd/apps/kvmd/api/streamer.py
index a3bbbe8b..995ed836 100644
--- a/kvmd/apps/kvmd/api/streamer.py
+++ b/kvmd/apps/kvmd/api/streamer.py
@@ -55,8 +55,8 @@ class StreamerApi:
return make_json_response(await self.__streamer.get_state())
@exposed_http("GET", "/streamer/snapshot")
- async def __make_snapshot_handler(self, request: Request) -> Response:
- if (snapshot := await self.__streamer.make_snapshot(
+ async def __take_snapshot_handler(self, request: Request) -> Response:
+ if (snapshot := await self.__streamer.take_snapshot(
save=valid_bool(request.query.get("save", "false")),
load=valid_bool(request.query.get("load", "false")),
allow_offline=valid_bool(request.query.get("allow_offline", "false")),
diff --git a/kvmd/apps/kvmd/snapshoter.py b/kvmd/apps/kvmd/snapshoter.py
index d6666967..69ef0dc0 100644
--- a/kvmd/apps/kvmd/snapshoter.py
+++ b/kvmd/apps/kvmd/snapshoter.py
@@ -81,7 +81,7 @@ class Snapshoter: # pylint: disable=too-many-instance-attributes
while True:
live = is_live()
if last_snapshot_ts + (self.__live_interval if live else self.__idle_interval) < time.time():
- await self.__make_snapshot(live, notifier)
+ await self.__take_snapshot(live, notifier)
last_snapshot_ts = time.time()
await asyncio.sleep(min(self.__idle_interval, self.__live_interval))
else:
@@ -90,9 +90,9 @@ class Snapshoter: # pylint: disable=too-many-instance-attributes
def snapshoting(self) -> bool:
return self.__snapshoting
- async def __make_snapshot(self, live: bool, notifier: aiotools.AioNotifier) -> None:
+ async def __take_snapshot(self, live: bool, notifier: aiotools.AioNotifier) -> None:
logger = get_logger(0)
- logger.info("Time to make the new snapshot (%s)", ("live" if live else "idle"))
+ logger.info("Time to take the new snapshot (%s)", ("live" if live else "idle"))
try:
self.__snapshoting = True
await notifier.notify()
@@ -115,16 +115,16 @@ class Snapshoter: # pylint: disable=too-many-instance-attributes
retries = self.__retries
while retries:
- snapshot = await self.__streamer.make_snapshot(save=True, load=False, allow_offline=False)
+ snapshot = await self.__streamer.take_snapshot(save=True, load=False, allow_offline=False)
if snapshot:
logger.info("New snapshot saved: %dx%d", snapshot.width, snapshot.height)
break
retries -= 1
await asyncio.sleep(self.__retries_delay)
else:
- logger.error("Can't make snapshot after %d retries", self.__retries)
+ logger.error("Can't take snapshot after %d retries", self.__retries)
except Exception: # Этого вообще-то не должно случаться, апи внутри заэксцепчены, но мало ли
- logger.exception("Unhandled exception while making snapshot")
+ logger.exception("Unhandled exception while taking snapshot")
finally:
self.__snapshoting = False
await notifier.notify()
diff --git a/kvmd/apps/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py
index 982bedea..5b239572 100644
--- a/kvmd/apps/kvmd/streamer.py
+++ b/kvmd/apps/kvmd/streamer.py
@@ -245,7 +245,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
# =====
- async def make_snapshot(self, save: bool, load: bool, allow_offline: bool) -> Optional[StreamerSnapshot]:
+ async def take_snapshot(self, save: bool, load: bool, allow_offline: bool) -> Optional[StreamerSnapshot]:
if load:
return self.__snapshot
else:
@@ -280,7 +280,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
return snapshot
logger.error("Stream is offline, no signal or so")
except (aiohttp.ClientConnectionError, aiohttp.ServerConnectionError) as err:
- logger.error("Can't make snapshot: %s: %s", type(err).__name__, err)
+ logger.error("Can't connect to streamer: %s: %s", type(err).__name__, err)
except Exception:
logger.exception("Invalid streamer response from /snapshot")
return None