I’ve been diggin’ and diggin’ about 2 hours but I couldn’t find a reason for this error:
1) JBoss
2) Tomcat
Select an application: 1
<App id="1" type="JBoss" path="" state="ok"/>
Traceback (most recent call last):
File "/root/RService.py", line 47, in <module>
Stats = app.getAttribute('state')
AttributeError: 'lxml.etree._Element' object has no attribute 'getAttribute'
And part of my code is:
app_types = set(nXML.xpath('//Group[@id=$gList]//descendant::App/@type',gList=gList))
app_dict = dict((x+1,y) for (x,y) in enumerate(app_types))
print "\n".join("%d) %s" % x for x in sorted(app_dict.items()))
app_selection = input("Select an application: ")
app_type = app_dict.get(int(app_selection))
for app in nXML.xpath('//Group[@id=$gList]//App[@type=$app_type]',gList=gList,app_type=app_type):
print etree.tostring(app)
Stats = app.getAttribute('state')
stype = app.getAttribute('type')
trigger = 0
while trigger < 1:
if Stats == 'ok':
try: ... ...
It was working before, what happened to the syntax?
Thanks
Try app.get(‘state’) instead. That works for me with LXML 2.2.7.