# Path: fluxghost/g.py
# USBDEVS = {}


from io import BytesIO
from uuid import UUID
from fluxclient.device.host2host_usb import FluxUSBError
from fluxclient.robot.errors import RobotError, RobotSessionError
from fluxclient.robot.robot import FluxRobot
from fluxclient.utils.version import StrictVersion
from fluxclient.encryptor import KeyObject
from fluxghost import g
import logging
import socket
                else:
                    self.send_fatal("NOT_FOUND")

            elif endpoint_type == "h2h":
                usbprotocol = g.USBDEVS.get(endpoint_target)
                self.send_text(STAGE_CONNECTIONG)

                if usbprotocol:
                    try:
                        self.remote_version = usbprotocol.version
                        self.robot = self.get_robot_from_h2h(usbprotocol)
                    except FluxUSBError:
                        logger.exception("USB control open failed.")
                        usbprotocol.stop()
                        raise RuntimeError("PROTOCOL_ERROR")
                else:
                    logger.debug(
                        "Try to connect to unknown device (addr=%s)",
                        endpoint_target)
                    raise RuntimeError("UNKNOWN_DEVICE")
            else:
                self.send_fatal("?")

            self.send_text(STAGE_CONNECTED)
            self.POOL_TIME = 30.0
            self.on_connected()

        def on_text_message(self, message):
            if self.client_key:
                self.on_command(message)

# Path: fluxghost/g.py
# USBDEVS = {}


# Path: fluxghost/api/control_base.py
from io import BytesIO
from uuid import UUID
from fluxclient.device.host2host_usb import FluxUSBError
from fluxclient.robot.errors import RobotError, RobotSessionError
from fluxclient.robot.robot import FluxRobot
from fluxclient.utils.version import StrictVersion
from fluxclient.encryptor import KeyObject
from fluxghost import g
import logging
import socket

                else:
                    self.send_fatal("NOT_FOUND")

            elif endpoint_type == "h2h":
                usbprotocol = g.USBDEVS.get(endpoint_target)
                self.send_text(STAGE_CONNECTIONG)

                if usbprotocol:
                    try:
                        self.remote_version = usbprotocol.version
                        self.robot = self.get_robot_from_h2h(usbprotocol)
                    except FluxUSBError:
                        logger.exception("USB control open failed.")
                        usbprotocol.stop()
                        raise RuntimeError("PROTOCOL_ERROR")
                else:
                    logger.debug(
                        "Try to connect to unknown device (addr=%s)",
                        endpoint_target)
                    raise RuntimeError("UNKNOWN_DEVICE")
            else:
                self.send_fatal("?")

            self.send_text(STAGE_CONNECTED)
            self.POOL_TIME = 30.0
            self.on_connected()

        def on_text_message(self, message):
            if self.client_key:
                self.on_command(message)

            else: