Finishing work on Issue #52

This commit is contained in:
Miroslav Stampar 2012-07-03 22:13:01 +02:00
parent 40fc6488bf
commit 23fb753759

View File

@ -5,6 +5,7 @@ Copyright (c) 2006-2012 sqlmap developers (http://www.sqlmap.org/)
See the file 'doc/COPYING' for copying permission See the file 'doc/COPYING' for copying permission
""" """
import os
import re import re
import time import time
@ -25,31 +26,39 @@ def update():
if not conf.updateAll: if not conf.updateAll:
return return
success = False
rootDir = paths.SQLMAP_ROOT_PATH rootDir = paths.SQLMAP_ROOT_PATH
infoMsg = "updating sqlmap to the latest development version from the " if not os.path.exists(os.path.join(rootDir, ".git")):
infoMsg += "GitHub repository" errMsg = "not a git repository. Please checkout the 'sqlmapproject/sqlmap' repository "
logger.info(infoMsg) errMsg += "from GitHub (e.g. git clone https://github.com/sqlmapproject/sqlmap.git sqlmap-dev)"
logger.error(errMsg)
debugMsg = "sqlmap will try to update itself using 'git' command"
logger.debug(debugMsg)
dataToStdout("\r[%s] [INFO] update in progress " % time.strftime("%X"))
process = execute("git pull %s" % rootDir, shell=True, stdout=PIPE, stderr=PIPE)
pollProcess(process, True)
stdout, stderr = process.communicate()
if not process.returncode:
logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", REVISION))
else: else:
logger.error("update could not be completed (%s)" % repr(stderr)) infoMsg = "updating sqlmap to the latest development version from the "
infoMsg += "GitHub repository"
logger.info(infoMsg)
debugMsg = "sqlmap will try to update itself using 'git' command"
logger.debug(debugMsg)
dataToStdout("\r[%s] [INFO] update in progress " % time.strftime("%X"))
process = execute("git pull %s" % rootDir, shell=True, stdout=PIPE, stderr=PIPE)
pollProcess(process, True)
stdout, stderr = process.communicate()
success = not process.returncode
if success:
logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", REVISION))
else:
logger.error("update could not be completed ('%s')" % re.sub(r"\W+", " ", stderr).strip())
if not success:
if IS_WIN: if IS_WIN:
infoMsg = "for Windows platform it's recommended " infoMsg = "for Windows platform it's recommended "
infoMsg += "to use a GitHub for Windows client for updating " infoMsg += "to use a GitHub for Windows client for updating "
infoMsg += "purposes (http://windows.github.com/)" infoMsg += "purposes (http://windows.github.com/)"
else: else:
infoMsg = "for Linux platform it's recommended " infoMsg = "for Linux platform it's required "
infoMsg += "to use a standard 'git' package (e.g.: 'sudo apt-get install git')" infoMsg += "to install a standard 'git' package (e.g.: 'sudo apt-get install git')"
logger.info(infoMsg) logger.info(infoMsg)