Replacing old and deprecated raise Exception style (PEP8)

This commit is contained in:
Miroslav Stampar
2013-01-03 23:20:55 +01:00
parent 3a11d36c66
commit e4a3c015e5
78 changed files with 260 additions and 260 deletions

View File

@@ -199,7 +199,7 @@ def decodePage(page, contentEncoding, contentType):
data = gzip.GzipFile("", "rb", 9, StringIO.StringIO(page))
size = struct.unpack("<l", page[-4:])[0] # Reference: http://pydoc.org/get.cgi/usr/local/lib/python2.5/gzip.py
if size > MAX_CONNECTION_TOTAL_SIZE:
raise Exception, "size too large"
raise Exception("size too large")
page = data.read()
except Exception, msg:

View File

@@ -92,7 +92,7 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
errMsg = "problem occured while retrieving original page content "
errMsg += "which prevents sqlmap from continuation. Please rerun, "
errMsg += "and if the problem persists turn off any optimization switches"
raise SqlmapNoneDataException, errMsg
raise SqlmapNoneDataException(errMsg)
ratio = 1. * pageLength / len(seqMatcher.a)

View File

@@ -466,11 +466,11 @@ class Connect(object):
if e.code == httplib.UNAUTHORIZED:
errMsg = "not authorized, try to provide right HTTP "
errMsg += "authentication type and valid credentials (%d)" % code
raise SqlmapConnectionException, errMsg
raise SqlmapConnectionException(errMsg)
elif e.code == httplib.NOT_FOUND:
if raise404:
errMsg = "page not found (%d)" % code
raise SqlmapConnectionException, errMsg
raise SqlmapConnectionException(errMsg)
else:
debugMsg = "page not found (%d)" % code
logger.debug(debugMsg)
@@ -488,7 +488,7 @@ class Connect(object):
logger.critical(warnMsg)
return None, None, None
else:
raise SqlmapConnectionException, warnMsg
raise SqlmapConnectionException(warnMsg)
else:
debugMsg = "got HTTP error code: %d (%s)" % (code, status)
logger.debug(debugMsg)
@@ -498,7 +498,7 @@ class Connect(object):
if "no host given" in tbMsg:
warnMsg = "invalid url address used (%s)" % repr(url)
raise SqlmapSyntaxException, warnMsg
raise SqlmapSyntaxException(warnMsg)
elif "forcibly closed" in tbMsg:
warnMsg = "connection was forcibly closed by the target url"
elif "timed out" in tbMsg:
@@ -531,7 +531,7 @@ class Connect(object):
logger.critical(warnMsg)
return None, None, None
else:
raise SqlmapConnectionException, warnMsg
raise SqlmapConnectionException(warnMsg)
finally:
page = page if isinstance(page, unicode) else getUnicode(page)
@@ -600,7 +600,7 @@ class Connect(object):
if not isinstance(payload, basestring):
errMsg = "tamper function '%s' returns " % function.func_name
errMsg += "invalid payload type ('%s')" % type(payload)
raise SqlmapValueException, errMsg
raise SqlmapValueException(errMsg)
value = agent.replacePayload(value, payload)

View File

@@ -57,7 +57,7 @@ class HTTPSConnection(httplib.HTTPSConnection):
logger.debug("SSL connection error occured ('%s')" % errMsg)
if not success:
raise SqlmapConnectionException, "can't establish SSL connection"
raise SqlmapConnectionException("can't establish SSL connection")
class HTTPSHandler(urllib2.HTTPSHandler):
def https_open(self, req):

View File

@@ -394,7 +394,7 @@ def getValue(expression, blind=True, union=True, error=True, time=True, fromUser
else:
errMsg = "none of the injection types identified can be "
errMsg += "leveraged to retrieve queries output"
raise SqlmapNotVulnerableException, errMsg
raise SqlmapNotVulnerableException(errMsg)
finally:
kb.resumeValues = True

View File

@@ -25,7 +25,7 @@ class ProxyHTTPConnection(httplib.HTTPConnection):
proto, rest = urllib.splittype(url)
if proto is None:
raise ValueError, "unknown URL type: %s" % url
raise ValueError("unknown URL type: %s" % url)
# Get host
host, rest = urllib.splithost(rest)
@@ -38,7 +38,7 @@ class ProxyHTTPConnection(httplib.HTTPConnection):
try:
port = self._ports[proto]
except KeyError:
raise ValueError, "unknown protocol for: %s" % url
raise ValueError("unknown protocol for: %s" % url)
self._real_host = host
self._real_port = int(port)
@@ -117,4 +117,4 @@ else:
class ProxyHTTPSHandler:
def __init__(self, *args, **kwargs):
errMsg = "unsupported feature on versions of Python before 2.6"
raise SqlmapUnsupportedFeatureException, errMsg
raise SqlmapUnsupportedFeatureException(errMsg)

View File

@@ -47,4 +47,4 @@ class HTTPRangeHandler(urllib2.BaseHandler):
def http_error_416(self, req, fp, code, msg, hdrs):
# HTTP's Range Not Satisfiable error
errMsg = "Invalid range"
raise SqlmapConnectionException, errMsg
raise SqlmapConnectionException(errMsg)

View File

@@ -110,4 +110,4 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
if hasattr(req, 'redirect_dict') and (req.redirect_dict.get(req.get_full_url(), 0) >= MAX_SINGLE_URL_REDIRECTIONS or len(req.redirect_dict) >= MAX_TOTAL_REDIRECTIONS):
errMsg = "infinite redirect loop detected (%s). " % ", ".join(item for item in req.redirect_dict.keys())
errMsg += "please check all provided parameters and/or provide missing ones."
raise SqlmapConnectionException, errMsg
raise SqlmapConnectionException(errMsg)