fix python compatibility in tomcat module
paulfantom committed
Jul 27, 2016 at 00:10 UTC
0ec589942e601528d6702f6dc12370b2e50c0502
1 file changed
+4
-3
python.d/tomcat.chart.py
+4
-3
@@ -6,7 +6,7 @@
6
7
from base import UrlService
8
import xml.etree.ElementTree as ET # phone home...
9
-import xml.parsers.expat.errors as errors
9
+#from xml.parsers.expat import errors
10
11
# default module values (can be overridden per job in `config`)
12
# update_every = 2
@@ -81,7 +81,8 @@ class Service(UrlService):
81
try:
82
data = ET.fromstring(raw)
83
except ET.ParseError as e:
84
- if e.code == errors.codes[errors.XML_ERROR_JUNK_AFTER_DOC_ELEMENT]:
84
+ #if e.code == errors.codes[errors.XML_ERROR_JUNK_AFTER_DOC_ELEMENT]:
85
+ if e.code == 9:
86
# cut rest of invalid string
87
pos = 0
88
for i in range(e.position[0] - 1):
@@ -89,7 +90,7 @@ class Service(UrlService):
90
raw = raw[:47604 + pos + e.position[0] - 1]
91
data = ET.fromstring(raw)
92
else:
92
- raise ET.ParseError(e)
93
+ raise Exception(e)
94
95
memory = data.find('./jvm/memory')
96
threads = data.find("./connector[@name='\"http-bio-" + str(self.port) + "\"']/threadInfo")