# 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
        raise RuntimeError("Unknow platform!!")

    def on_close(self, *args, **kw):
        super(WebsocketConfig, self).on_close(*args, **kw)
        try:
            self.db.close()
        except:
            pass

    def on_text_message(self, message):
        op, self.key = message.split(maxsplit=1)
        logger.debug('will store in %s' % (self.config_path + self.config_file))

        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:

# 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

        raise RuntimeError("Unknow platform!!")

    def on_close(self, *args, **kw):
        super(WebsocketConfig, self).on_close(*args, **kw)
        try:
            self.db.close()
        except:
            pass

    def on_text_message(self, message):
        op, self.key = message.split(maxsplit=1)
        logger.debug('will store in %s' % (self.config_path + self.config_file))

        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")