# Path: fluxghost/websocket/base.py
# class WebSocketBase(WebSocketHandler, ApiBase):
#     TIMEOUT = 600
#     def __init__(self, request, client, server, path):
#     def serve_forever(self):
#     def send_fatal(self, *args):
#     def on_read(self):
#     def _on_loop(self):
#     def check_ttl(self):
#     def close(self, error=False, message=None):


import logging
import platform
import dbm
import sys
from os.path import expanduser
from .base import WebSocketBase, BinaryUploadHelper, WebsocketBinaryHelperMixin
        try:
            if self.operation:
                raise RuntimeError("CONFIG_FILE_ALREADY_OPENED")

            if op == WRITE_OP:
                self.operation = WRITE_OP
                self.db = dbm.open(self.config_path + self.config_file, 'c')
                self.send('{"status": "opened"}')
                self.begin_recv_binary(self.key)

            elif op == READ_OP:
                self.operation = READ_OP
                self.db = dbm.open(self.config_path + self.config_file, 'c')
                self.send('{"status": "opened"}')
                self.read_key()

            else:
                raise RuntimeError("BAD_FILE_OPERATION")

        except RuntimeError as e:
            self.send_error(e.args[0])
            self.close()

        except PermissionError:
            self.send_error("ACCESS_DENY")
            self.close()
        except Exception as e:
            self.send_error(e)
            self.close()


# Path: fluxghost/websocket/base.py
# class WebSocketBase(WebSocketHandler, ApiBase):
#     TIMEOUT = 600
#     def __init__(self, request, client, server, path):
#     def serve_forever(self):
#     def send_fatal(self, *args):
#     def on_read(self):
#     def _on_loop(self):
#     def check_ttl(self):
#     def close(self, error=False, message=None):


# Path: fluxghost/websocket/config.py
import logging
import platform
import dbm
import sys
from os.path import expanduser
from .base import WebSocketBase, BinaryUploadHelper, WebsocketBinaryHelperMixin

        try:
            if self.operation:
                raise RuntimeError("CONFIG_FILE_ALREADY_OPENED")

            if op == WRITE_OP:
                self.operation = WRITE_OP
                self.db = dbm.open(self.config_path + self.config_file, 'c')
                self.send('{"status": "opened"}')
                self.begin_recv_binary(self.key)

            elif op == READ_OP:
                self.operation = READ_OP
                self.db = dbm.open(self.config_path + self.config_file, 'c')
                self.send('{"status": "opened"}')
                self.read_key()

            else:
                raise RuntimeError("BAD_FILE_OPERATION")

        except RuntimeError as e:
            self.send_error(e.args[0])
            self.close()

        except PermissionError:
            self.send_error("ACCESS_DENY")
            self.close()
        except Exception as e:
            self.send_error(e)
            self.close()


    def read_key(self):