示例#1
0
文件: ospd.py 项目: janowagner/ospd
    def get_xml_str(self, data: Dict) -> List:
        """ Creates a string in XML Format using the provided data structure.

        @param: Dictionary of xml tags and their elements.

        @return: String of data in xml format.
        """
        return get_elements_from_dict(data)
示例#2
0
    def handle_xml(self, xml: Element) -> bytes:
        help_format = xml.get('format')

        if help_format is None or help_format == "text":
            # Default help format is text.
            return simple_response_str('help', 200, 'OK',
                                       self._daemon.get_help_text())
        elif help_format == "xml":
            text = get_elements_from_dict(
                {k: v.as_dict()
                 for k, v in self._daemon.commands.items()})
            return simple_response_str('help', 200, 'OK', text)

        raise OspdCommandError('Bogus help format', 'help')