From 3487429eac0b50defaf70b37c2bc007b1c61d5e2 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 16 Nov 2010 14:41:46 +0000 Subject: [PATCH] minor cosmetics --- lib/core/common.py | 11 ++++++----- lib/request/connect.py | 16 +++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 815f47035..cd8a2675b 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1519,11 +1519,12 @@ def extractErrorMessage(page): retVal = None - for regex in (r"[^<]*(fatal|error|warning|exception)[^<]*:?\s+(?P.+)", r"
  • Error Type:
    (?P.+?)
  • "): - match = re.search(regex, page, re.DOTALL | re.IGNORECASE) - if match: - retVal = htmlunescape(match.group("result")) - break + if isinstance(page, basestring): + for regex in (r"[^<]*(fatal|error|warning|exception)[^<]*:?\s+(?P.+)", r"
  • Error Type:
    (?P.+?)
  • "): + match = re.search(regex, page, re.DOTALL | re.IGNORECASE) + if match: + retVal = htmlunescape(match.group("result")).replace("
    ", "\n").strip() + break return retVal diff --git a/lib/request/connect.py b/lib/request/connect.py index f26cb2600..20f0cf076 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -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