pc -> server

This commit is contained in:
Devaev Maxim
2018-07-03 00:43:31 +03:00
parent 8fd506fa1b
commit c4d861cc35
2 changed files with 5 additions and 5 deletions

View File

@@ -30,7 +30,7 @@ class IsNotOperationalError(MassStorageError):
class AlreadyConnectedToPcError(MassStorageError): class AlreadyConnectedToPcError(MassStorageError):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__("Mass-storage is already connected to PC") super().__init__("Mass-storage is already connected to Server")
class AlreadyConnectedToKvmError(MassStorageError): class AlreadyConnectedToKvmError(MassStorageError):
@@ -180,12 +180,12 @@ class MassStorageDevice: # pylint: disable=too-many-instance-attributes
raise AlreadyConnectedToPcError() raise AlreadyConnectedToPcError()
# TODO: enable gpio # TODO: enable gpio
self.__device_info = None self.__device_info = None
get_logger().info("Mass-storage device switched to PC") get_logger().info("Mass-storage device switched to Server")
def get_state(self) -> Dict: def get_state(self) -> Dict:
return { return {
"in_operate": bool(self._bind), "in_operate": bool(self._bind),
"connected_to": ("kvm" if self.__device_info else "pc"), "connected_to": ("kvm" if self.__device_info else "server"),
"is_busy": bool(self._device_file), "is_busy": bool(self._device_file),
"writed": self.__writed, "writed": self.__writed,
"info": (self.__device_info._asdict() if self.__device_info else None), "info": (self.__device_info._asdict() if self.__device_info else None),

View File

@@ -159,9 +159,9 @@ class Server: # pylint: disable=too-many-instance-attributes
if to == "kvm": if to == "kvm":
await self.__msd.connect_to_kvm() await self.__msd.connect_to_kvm()
await self.__broadcast_event("msd_state", state="connected_to_kvm") # type: ignore await self.__broadcast_event("msd_state", state="connected_to_kvm") # type: ignore
elif to == "pc": elif to == "server":
await self.__msd.connect_to_pc() await self.__msd.connect_to_pc()
await self.__broadcast_event("msd_state", state="connected_to_pc") # type: ignore await self.__broadcast_event("msd_state", state="connected_to_server") # type: ignore
else: else:
raise RuntimeError("Missing or invalid 'to=%s'" % (to)) raise RuntimeError("Missing or invalid 'to=%s'" % (to))
return _json_200(self.__msd.get_state()) return _json_200(self.__msd.get_state())