more quick fixes

This commit is contained in:
Miroslav Stampar 2010-05-04 08:43:14 +00:00
parent af701cdaa2
commit 789dd6c66f
2 changed files with 9 additions and 5 deletions

View File

@ -1027,7 +1027,10 @@ def safeStringFormat(formatStr, params):
return retVal return retVal
def sanitizeAsciiString(subject): def sanitizeAsciiString(subject):
return "".join(char if ord(char) < 128 else '?' for char in subject) retVal = None
if subject:
retVal = "".join(char if ord(char) < 128 else '?' for char in subject)
return retVal
def decloakToNamedTemporaryFile(filepath, name=None): def decloakToNamedTemporaryFile(filepath, name=None):
retVal = NamedTemporaryFile() retVal = NamedTemporaryFile()

View File

@ -203,10 +203,11 @@ class Connect:
page = e.read() page = e.read()
responseHeaders = e.info() responseHeaders = e.info()
except socket.timeout: except socket.timeout:
page, responseHeaders = None, None
warnMsg = "connection timed out while trying " warnMsg = "connection timed out while trying "
warnMsg += "to get error page information" warnMsg += "to get error page information"
logger.warn(warnMsg) logger.warn(warnMsg)
page, responseHeaders = None, None return None, None
code = e.code code = e.code
status = e.msg status = e.msg
@ -249,8 +250,8 @@ class Connect:
socket.setdefaulttimeout(conf.timeout) socket.setdefaulttimeout(conf.timeout)
page = sanitizeAsciiString(page) page = sanitizeAsciiString(page)
parseResponse(page, responseHeaders) parseResponse(page, responseHeaders)
responseMsg += "(%s - %d):\n" % (status, code) responseMsg += "(%s - %d):\n" % (status, code)
if conf.verbose <= 4: if conf.verbose <= 4: