def parse_request(self, request):

        try:
            request = anyjson.deserialize(request['data'])
        except __HOLE__, e:
            logging.error("Request dictionary contains no 'data' key")
            return self.encode_result((500, "Internal error with request"))
        except Exception, e:
            logging.error("Invalid JSON in 'data' key for request")
            return self.encode_result((500, "Request is malformed"))

        try:
            cmd_name = request['name']
        except KeyError:
            logging.error("Request is missing 'name' key")
            return self.encode_result((500, "Request is missing 'name' key"))
        cmd_string = request.get('value', '')

        # XXX Major kludge here to not log activation keys for redhat
        if isinstance(cmd_string, dict) and \
                'activation_key' in cmd_string:
            cs_copy = cmd_string.copy()
            cs_copy['activation_key'] = "<removed>"
            logging.info("Received command '%s' with argument: '%s'" % \
                (cmd_name, cs_copy))
        else:
            logging.info("Received command '%s' with argument: '%s'" % \
                (cmd_name, cmd_string))

        try:
            result = self._command_cls.run_command(cmd_name, cmd_string)
        except self._command_cls.CommandNotFoundError, e:
            logging.warn(str(e))
            return self.encode_result((404, str(e)))
        except Exception, e:
            logging.exception('Exception while trying to process '
                    'command %r' % cmd_name)
            return self.encode_result((500, str(e)))

        logging.info("'%s' completed with code '%s', message '%s'" % \
                (cmd_name, result[0], result[1]))

        return self.encode_result(result)
dataset/ETHPy150Open rackerlabs/openstack-guest-agents-unix/plugins/jsonparser.py/JsonParser.parse_request