I am trying to parse out some values from the results of an easysnmp SNMP query but it is not working as expected.
The following results in an error:
from ttp import ttp
a = "<SNMPVariable value='1' (oid='enterprises.4998.1.1.20.2.33.1.5.16.86.17.126.66.140.34214089.5', oid_index='', snmp_type='INTEGER')>"
t = "<SNMPVariable value='{{value}}' (oid='{{oid}}', oid_index='{{oid_index}}', snmp_type='{{snmp_type}}')>"
p = ttp(a,t)
Traceback (most recent call last):
File "C:UsersmeAppDataLocalProgramsPythonPython37libsite-packagestptp.py", line 1168, in parse_template_XML
template_ET = ET.XML(template_text)
File "C:UsersmeAppDataLocalProgramsPythonPython37libxmletreeElementTree.py", line 1315, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 32
If I remove the wedges from the string I do not get an error, but I don't get the values I'm looking for:
from ttp import ttp
a = "SNMPVariable value='1' (oid='enterprises.4998.1.1.20.2.33.1.5.16.86.17.126.66.140.34214089.5', oid_index='', snmp_type='INTEGER')"
t = "SNMPVariable value='{{value}}' (oid='{{oid}}', oid_index='{{oid_index}}', snmp_type='{{snmp_type}}')"
p = ttp(a,t)
p.parse()
p.result()
[[{}]]
What I expect to get for output is:
[[{'value':'1', 'oid':'enterprises.4998.1.1.20.2.33.1.5.16.86.17.126.66.140.34214089.5', 'oid_index'='', 'snmp_type': 'INTEGER'}]]
I know I'm overlooking something obvious, but I cannot figure it out. Any suggestions?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…