10 from Queue
import Queue
12 from queue
import Queue
15 from xml.sax.saxutils
import escape
19 def __init__(self, host, port, max_retry, encoding="utf-8"):
20 super(ModuleClient, self).
__init__(host, port, max_retry)
24 data = os.linesep.join(cmds) + os.linesep
29 parsed = data.split(
"." + os.linesep)
31 raise ValueError(
"Received data too short")
32 parsed_data = [self.
parse_xml(d)
for d
in parsed[:-1]]
33 parsed_length = len(data) - len(parsed[-1])
34 return parsed_data, parsed_length
38 if sys.version_info.major < 3:
41 xml = lxml.etree.fromstring(data)
43 except Exception
as e:
47 parsed = data.split(
'"')
48 for i
in range(len(parsed))[1::2]:
49 parsed[i] = escape(parsed[i])
50 return '"'.
join(parsed)
52 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")