mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-07-29 09:29:50 +03:00
Refactoring for Python 3 raise
* 2to3 `ls | grep -v thirdparty` -f raise
This commit is contained in:
parent
158b529930
commit
1b03ce2a3c
|
@ -90,7 +90,7 @@ class BigArray(list):
|
|||
except IOError as ex:
|
||||
errMsg = "exception occurred while retrieving data "
|
||||
errMsg += "from a temporary file ('%s')" % ex.message
|
||||
raise SqlmapSystemException, errMsg
|
||||
raise SqlmapSystemException(errMsg)
|
||||
|
||||
return self.chunks[-1].pop()
|
||||
|
||||
|
@ -115,7 +115,7 @@ class BigArray(list):
|
|||
errMsg += "make sure that there is enough disk space left. If problem persists, "
|
||||
errMsg += "try to set environment variable 'TEMP' to a location "
|
||||
errMsg += "writeable by the current user"
|
||||
raise SqlmapSystemException, errMsg
|
||||
raise SqlmapSystemException(errMsg)
|
||||
|
||||
def _checkcache(self, index):
|
||||
if (self.cache and self.cache.index != index and self.cache.dirty):
|
||||
|
@ -129,7 +129,7 @@ class BigArray(list):
|
|||
except IOError as ex:
|
||||
errMsg = "exception occurred while retrieving data "
|
||||
errMsg += "from a temporary file ('%s')" % ex.message
|
||||
raise SqlmapSystemException, errMsg
|
||||
raise SqlmapSystemException(errMsg)
|
||||
|
||||
def __getstate__(self):
|
||||
return self.chunks, self.filenames
|
||||
|
|
|
@ -2005,7 +2005,7 @@ def parseXmlFile(xmlFile, handler):
|
|||
errMsg = "something appears to be wrong with "
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (xmlFile, getSafeExString(ex))
|
||||
errMsg += "sure that you haven't made any changes to it"
|
||||
raise SqlmapInstallationException, errMsg
|
||||
raise SqlmapInstallationException(errMsg)
|
||||
|
||||
def getSQLSnippet(dbms, sfile, **variables):
|
||||
"""
|
||||
|
|
|
@ -80,7 +80,7 @@ def base64unpickle(value, unsafe=False):
|
|||
if len(self.stack) > 1:
|
||||
func = self.stack[-2]
|
||||
if func not in PICKLE_REDUCE_WHITELIST:
|
||||
raise Exception, "abusing reduce() is bad, Mkay!"
|
||||
raise Exception("abusing reduce() is bad, Mkay!")
|
||||
self.load_reduce()
|
||||
|
||||
def loads(str):
|
||||
|
|
|
@ -337,7 +337,7 @@ def _feedTargetsDict(reqFile, addedTargetUrls):
|
|||
|
||||
if not host:
|
||||
errMsg = "invalid format of a request file"
|
||||
raise SqlmapSyntaxException, errMsg
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
if not url.startswith("http"):
|
||||
url = "%s://%s:%s%s" % (scheme or "http", host, port or "80", url)
|
||||
|
@ -402,7 +402,7 @@ def _loadQueries():
|
|||
errMsg = "something appears to be wrong with "
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (paths.QUERIES_XML, getSafeExString(ex))
|
||||
errMsg += "sure that you haven't made any changes to it"
|
||||
raise SqlmapInstallationException, errMsg
|
||||
raise SqlmapInstallationException(errMsg)
|
||||
|
||||
for node in tree.findall("*"):
|
||||
queries[node.attrib['value']] = iterate(node)
|
||||
|
@ -1128,7 +1128,7 @@ def _setHTTPHandlers():
|
|||
_ = urlparse.urlsplit(conf.proxy)
|
||||
except Exception as ex:
|
||||
errMsg = "invalid proxy address '%s' ('%s')" % (conf.proxy, getSafeExString(ex))
|
||||
raise SqlmapSyntaxException, errMsg
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
hostnamePort = _.netloc.split(":")
|
||||
|
||||
|
@ -1255,7 +1255,7 @@ def _setSafeVisit():
|
|||
kb.safeReq.post = None
|
||||
else:
|
||||
errMsg = "invalid format of a safe request file"
|
||||
raise SqlmapSyntaxException, errMsg
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
else:
|
||||
if not re.search(r"\Ahttp[s]*://", conf.safeUrl):
|
||||
if ":443/" in conf.safeUrl:
|
||||
|
@ -1580,7 +1580,7 @@ def _createTemporaryDirectory():
|
|||
except (OSError, IOError) as ex:
|
||||
errMsg = "there has been a problem while accessing "
|
||||
errMsg += "temporary directory location(s) ('%s')" % getSafeExString(ex)
|
||||
raise SqlmapSystemException, errMsg
|
||||
raise SqlmapSystemException(errMsg)
|
||||
else:
|
||||
try:
|
||||
if not os.path.isdir(tempfile.gettempdir()):
|
||||
|
@ -1607,7 +1607,7 @@ def _createTemporaryDirectory():
|
|||
except (OSError, IOError, WindowsError) as ex:
|
||||
errMsg = "there has been a problem while setting "
|
||||
errMsg += "temporary directory location ('%s')" % getSafeExString(ex)
|
||||
raise SqlmapSystemException, errMsg
|
||||
raise SqlmapSystemException(errMsg)
|
||||
|
||||
def _cleanupOptions():
|
||||
"""
|
||||
|
|
|
@ -47,7 +47,7 @@ class Wordlist(object):
|
|||
errMsg = "something appears to be wrong with "
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (self.current, getSafeExString(ex))
|
||||
errMsg += "sure that you haven't made any changes to it"
|
||||
raise SqlmapInstallationException, errMsg
|
||||
raise SqlmapInstallationException(errMsg)
|
||||
if len(_.namelist()) == 0:
|
||||
errMsg = "no file(s) inside '%s'" % self.current
|
||||
raise SqlmapDataException(errMsg)
|
||||
|
@ -73,7 +73,7 @@ class Wordlist(object):
|
|||
errMsg = "something appears to be wrong with "
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (self.current, getSafeExString(ex))
|
||||
errMsg += "sure that you haven't made any changes to it"
|
||||
raise SqlmapInstallationException, errMsg
|
||||
raise SqlmapInstallationException(errMsg)
|
||||
except StopIteration:
|
||||
self.adjust()
|
||||
retVal = self.iter.next().rstrip()
|
||||
|
|
|
@ -910,7 +910,7 @@ def cmdLineParser(argv=None):
|
|||
for arg in shlex.split(command):
|
||||
argv.append(getUnicode(arg, encoding=sys.stdin.encoding))
|
||||
except ValueError as ex:
|
||||
raise SqlmapSyntaxException, "something went wrong during command line parsing ('%s')" % ex.message
|
||||
raise SqlmapSyntaxException("something went wrong during command line parsing ('%s')" % ex.message)
|
||||
|
||||
for i in xrange(len(argv)):
|
||||
if argv[i] == "-hh":
|
||||
|
|
|
@ -78,7 +78,7 @@ def loadBoundaries():
|
|||
errMsg = "something appears to be wrong with "
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (paths.BOUNDARIES_XML, getSafeExString(ex))
|
||||
errMsg += "sure that you haven't made any changes to it"
|
||||
raise SqlmapInstallationException, errMsg
|
||||
raise SqlmapInstallationException(errMsg)
|
||||
|
||||
root = doc.getroot()
|
||||
parseXmlNode(root)
|
||||
|
@ -93,7 +93,7 @@ def loadPayloads():
|
|||
errMsg = "something appears to be wrong with "
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (payloadFilePath, getSafeExString(ex))
|
||||
errMsg += "sure that you haven't made any changes to it"
|
||||
raise SqlmapInstallationException, errMsg
|
||||
raise SqlmapInstallationException(errMsg)
|
||||
|
||||
root = doc.getroot()
|
||||
parseXmlNode(root)
|
||||
|
|
|
@ -32,7 +32,7 @@ def parseSitemap(url, retVal=None):
|
|||
content = Request.getPage(url=url, raise404=True)[0] if not abortedFlag else ""
|
||||
except httplib.InvalidURL:
|
||||
errMsg = "invalid URL given for sitemap ('%s')" % url
|
||||
raise SqlmapSyntaxException, errMsg
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
for match in re.finditer(r"<loc>\s*([^<]+)", content or ""):
|
||||
if abortedFlag:
|
||||
|
|
|
@ -982,7 +982,7 @@ class Connect(object):
|
|||
if not conf.csrfUrl:
|
||||
errMsg += ". You can try to rerun by providing "
|
||||
errMsg += "a valid value for option '--csrf-url'"
|
||||
raise SqlmapTokenException, errMsg
|
||||
raise SqlmapTokenException(errMsg)
|
||||
|
||||
if token:
|
||||
token = token.strip("'\"")
|
||||
|
|
|
@ -278,7 +278,7 @@ def setRestAPILog():
|
|||
conf.databaseCursor = Database(conf.database)
|
||||
conf.databaseCursor.connect("client")
|
||||
except sqlite3.OperationalError as ex:
|
||||
raise SqlmapConnectionException, "%s ('%s')" % (ex, conf.database)
|
||||
raise SqlmapConnectionException("%s ('%s')" % (ex, conf.database))
|
||||
|
||||
# Set a logging handler that writes log messages to a IPC database
|
||||
logger.removeHandler(LOGGER_HANDLER)
|
||||
|
|
|
@ -92,7 +92,7 @@ class HashDB(object):
|
|||
except sqlite3.DatabaseError as ex:
|
||||
errMsg = "error occurred while accessing session file '%s' ('%s'). " % (self.filepath, getSafeExString(ex))
|
||||
errMsg += "If the problem persists please rerun with `--flush-session`"
|
||||
raise SqlmapConnectionException, errMsg
|
||||
raise SqlmapConnectionException(errMsg)
|
||||
else:
|
||||
break
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class SQLAlchemy(GenericConnector):
|
|||
try:
|
||||
if not self.port and self.db:
|
||||
if not os.path.exists(self.db):
|
||||
raise SqlmapFilePathException, "the provided database file '%s' does not exist" % self.db
|
||||
raise SqlmapFilePathException("the provided database file '%s' does not exist" % self.db)
|
||||
|
||||
_ = conf.direct.split("//", 1)
|
||||
conf.direct = "%s////%s" % (_[0], os.path.abspath(self.db))
|
||||
|
|
Loading…
Reference in New Issue
Block a user