How to use the fbtftp.constants.ERR_FILE_NOT_FOUND function in fbtftp

To help you get started, we’ve selected a few fbtftp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / fbtftp / fbtftp / base_handler.py View on Github external
)
        self._family = socket.AF_INET6
        # the format of the peer tuple is different for v4 and v6
        if isinstance(ipaddress.ip_address(server_addr[0]), ipaddress.IPv4Address):
            self._family = socket.AF_INET
            # peer address format is different in v4 world
            self._peer = (self._peer[0].replace("::ffff:", ""), self._peer[1])

        self._stats = SessionStats(self._server_addr, self._peer, self._path)

        try:
            self._response_data = self.get_response_data()
        except FileNotFoundError as e:
            logging.warning(str(e))
            self._stats.error = {
                "error_code": constants.ERR_FILE_NOT_FOUND,
                "error_message": str(e),
            }
        except Exception as e:
            logging.exception("Caught exception: %s." % e)
            self._stats.error = {
                "error_code": constants.ERR_UNDEFINED,
                "error_message": str(e),
            }

        super().__init__()