8 from Queue
import Queue
11 from xml.sax.saxutils
import escape
15 def __init__(self, host, port, max_retry, encoding="utf-8"):
16 super(ModuleClient, self).
__init__(host, port, max_retry)
20 data = os.linesep.join(cmds) + os.linesep
25 parsed = data.split(
"." + os.linesep)
27 raise ValueError(
"Received data too short")
28 parsed_data = [self.
parse_xml(d)
for d
in parsed[:-1]]
29 parsed_length = len(data) - len(parsed[-1])
30 return parsed_data, parsed_length
36 xml = lxml.etree.fromstring(data)
38 except Exception
as e:
42 parsed = data.split(
'"')
43 for i
in range(len(parsed))[1::2]:
44 parsed[i] = escape(parsed[i])
45 return '"'.
join(parsed)
47 if __name__ ==
'__main__':
def parse_xml(self, data)
def send_command(self, cmds)
def validate_xml(self, data)
def __init__(self, host, port, max_retry, encoding="utf-8")