mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-03-23 19:34:13 +03:00
minor refactoring
This commit is contained in:
parent
5f44696530
commit
9b91b30b69
|
@ -1093,7 +1093,7 @@ def profile(profileOutputFile='sqlmap.profile', imageOutputFile='profile.png'):
|
||||||
|
|
||||||
graphScriptPath = os.path.join(paths.SQLMAP_EXTRAS_PATH, 'gprof2dot', 'gprof2dot.py')
|
graphScriptPath = os.path.join(paths.SQLMAP_EXTRAS_PATH, 'gprof2dot', 'gprof2dot.py')
|
||||||
|
|
||||||
infoMsg = "converting profile data to an image."
|
infoMsg = "converting profile data to a graph image."
|
||||||
logger.info(infoMsg)
|
logger.info(infoMsg)
|
||||||
|
|
||||||
if os.path.exists(imageOutputFile):
|
if os.path.exists(imageOutputFile):
|
||||||
|
@ -1102,15 +1102,29 @@ def profile(profileOutputFile='sqlmap.profile', imageOutputFile='profile.png'):
|
||||||
msg = subprocess.Popen('python %s -f pstats %s | dot -Tpng -o %s' % (graphScriptPath, profileOutputFile, imageOutputFile), shell=True, stderr=subprocess.PIPE).stderr.read()
|
msg = subprocess.Popen('python %s -f pstats %s | dot -Tpng -o %s' % (graphScriptPath, profileOutputFile, imageOutputFile), shell=True, stderr=subprocess.PIPE).stderr.read()
|
||||||
|
|
||||||
if msg:
|
if msg:
|
||||||
errMsg = "there was an error while converting ('%s')." % msg.strip()
|
errMsg = "there was an error while converting ('%s'), " % msg.strip()
|
||||||
|
errMsg += "but you can still find raw profile data "
|
||||||
|
errMsg += "inside file '%s'" % profileOutputFile
|
||||||
logger.error(errMsg)
|
logger.error(errMsg)
|
||||||
else:
|
else:
|
||||||
if os.name == 'mac':
|
try:
|
||||||
subprocess.call(('open', imageOutputFile))
|
if os.name == 'mac':
|
||||||
elif os.name == 'posix':
|
subprocess.call(('open', imageOutputFile))
|
||||||
subprocess.call(('xdg-open', imageOutputFile))
|
elif os.name == 'posix':
|
||||||
elif os.name == 'nt':
|
subprocess.call(('xdg-open', imageOutputFile))
|
||||||
subprocess.call(('start', imageOutputFile))
|
elif os.name == 'nt':
|
||||||
|
subprocess.call(('start', imageOutputFile))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if os.path.exists(imageOutputFile):
|
||||||
|
infoMsg = "done. you can find a graph image inside file '%s'." % imageOutputFile
|
||||||
|
logger.info(infoMsg)
|
||||||
|
else:
|
||||||
|
errMsg = "there was an error while converting, "
|
||||||
|
errMsg += "but you can still find raw profile data "
|
||||||
|
errMsg += "inside file '%s'" % profileOutputFile
|
||||||
|
logger.error(errMsg)
|
||||||
|
|
||||||
def getConsoleWidth(default=80):
|
def getConsoleWidth(default=80):
|
||||||
width = None
|
width = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user