btfxwss/connection.py
def _info_handler(self, data):
        """
        Handle INFO messages from the API and issues relevant actions.

        :param data:
        :param ts:
        """

        def raise_exception():
            """Log info code as error and raise a ValueError."""
            self.log.error("%s: %s", data['code'], info_message[data['code']])
            raise ValueError("%s: %s" % (data['code'], info_message[data['code']]))

        if 'code' not in data and 'version' in data:
            self.log.info('Initialized Client on API Version %s', data['version'])
            return

        info_message = {20000: 'Invalid User given! Please make sure the given ID is correct!',
                        20051: 'Stop/Restart websocket server '
                                 '(please try to reconnect)',
                        20060: 'Refreshing data from the trading engine; '
                                 'please pause any acivity.',
                        20061: 'Done refreshing data from the trading engine.'
                                 ' Re-subscription advised.'}

        codes = {20051: self.reconnect, 20060: self._pause,
                 20061: self._unpause}

        if 'version' in data:
            self.log.info("API version: %i", data['version'])
            return

        try:
            self.log.info(info_message[data['code']])
            codes[data['code']]()
        except KeyError as e:
            self.log.exception(e)
            self.log.error("Unknown Info code %s!", data['code'])
            raise
def _info_handler(self, data):
        """
        Handle INFO messages from the API and issues relevant actions.

        :param data:
        :param ts:
        """

        def raise_exception():
            """Log info code as error and raise a ValueError."""
            self.log.error("%s: %s", data['code'], info_message[data['code']])
            raise ValueError("%s: %s" % (data['code'], info_message[data['code']]))

        if 'code' not in data and 'version' in data:
            self.log.info('Initialized Client on API Version %s', data['version'])
            return

        info_message = {20000: 'Invalid User given! Please make sure the given ID is correct!',
                        20051: 'Stop/Restart websocket server '
                                 '(please try to reconnect)',
                        20060: 'Refreshing data from the trading engine; '
                                 'please pause any acivity.',
                        20061: 'Done refreshing data from the trading engine.'
                                 ' Re-subscription advised.'}

        codes = {20051: self.reconnect, 20060: self._pause,
                 20061: self._unpause}

        if 'version' in data:
            self.log.info("API version: %i", data['version'])
            return

        try:
            self.log.info(info_message[data['code']])
            codes[data['code']]()
        except KeyError as e:
            self.log.exception(e)
            self.log.error("Unknown Info code %s!", data['code'])
            raise
Handle INFO messages from the API and issues relevant actions.

        :param data:
        :param ts: