minor cosmetics

This commit is contained in:
Miroslav Stampar 2010-11-16 14:41:46 +00:00
parent 3640dbf745
commit 3487429eac
2 changed files with 11 additions and 16 deletions

View File

@ -1519,10 +1519,11 @@ def extractErrorMessage(page):
retVal = None
if isinstance(page, basestring):
for regex in (r"<b>[^<]*(fatal|error|warning|exception)[^<]*</b>:?\s+(?P<result>.+)<br\s*/?\s*>", r"<li>Error Type:<br>(?P<result>.+?)</li>"):
match = re.search(regex, page, re.DOTALL | re.IGNORECASE)
if match:
retVal = htmlunescape(match.group("result"))
retVal = htmlunescape(match.group("result")).replace("<br>", "\n").strip()
break
return retVal

View File

@ -220,11 +220,6 @@ class Connect:
responseHeaders = conn.info()
page = decodePage(page, responseHeaders.get("Content-Encoding"), responseHeaders.get("Content-Type"))
if conf.parseErrors:
msg = extractErrorMessage(page)
if msg:
logger.info("parsed error message: '%s'" % msg)
except urllib2.HTTPError, e:
code = e.code
status = e.msg
@ -240,12 +235,6 @@ class Connect:
try:
page = e.read()
responseHeaders = e.info()
if conf.parseErrors:
msg = extractErrorMessage(page)
if msg:
logger.info("parsed error message: '%s'" % msg)
except socket.timeout:
warnMsg = "connection timed out while trying "
warnMsg += "to get error page information (%d)" % code
@ -309,6 +298,11 @@ class Connect:
logger.log(7, responseMsg)
if conf.parseErrors:
msg = extractErrorMessage(page)
if msg:
logger.info("parsed error message: '%s'" % msg)
return page, responseHeaders
@staticmethod