|
17 | 17 | from lib.core.common import dataToStdout |
18 | 18 | from lib.core.common import getSafeExString |
19 | 19 | from lib.core.common import getLatestRevision |
| 20 | +from lib.core.common import getText |
20 | 21 | from lib.core.common import pollProcess |
21 | 22 | from lib.core.common import readInput |
22 | 23 | from lib.core.data import conf |
@@ -106,23 +107,25 @@ def update(): |
106 | 107 | dataToStdout("\r[%s] [INFO] update in progress" % time.strftime("%X")) |
107 | 108 |
|
108 | 109 | try: |
109 | | - process = subprocess.Popen("git checkout . && git pull %s HEAD" % GIT_REPOSITORY, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=paths.SQLMAP_ROOT_PATH.encode(sys.getfilesystemencoding() or UNICODE_ENCODING)) |
| 110 | + process = subprocess.Popen("git checkout . && git pull %s HEAD" % GIT_REPOSITORY, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=paths.SQLMAP_ROOT_PATH.encode(sys.getfilesystemencoding() or UNICODE_ENCODING)) |
110 | 111 | pollProcess(process, True) |
111 | | - stdout, stderr = process.communicate() |
| 112 | + output, _ = process.communicate() |
112 | 113 | success = not process.returncode |
113 | 114 | except (IOError, OSError) as ex: |
114 | 115 | success = False |
115 | | - stderr = getSafeExString(ex) |
| 116 | + output = getSafeExString(ex) |
| 117 | + finally: |
| 118 | + output = getText(output) |
116 | 119 |
|
117 | 120 | if success: |
118 | | - logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", getRevisionNumber())) |
| 121 | + logger.info("%s the latest revision '%s'" % ("already at" if "Already" in output else "updated to", getRevisionNumber())) |
119 | 122 | else: |
120 | | - if "Not a git repository" in stderr: |
| 123 | + if "Not a git repository" in output: |
121 | 124 | errMsg = "not a valid git repository. Please checkout the 'sqlmapproject/sqlmap' repository " |
122 | 125 | errMsg += "from GitHub (e.g. 'git clone --depth 1 %s sqlmap')" % GIT_REPOSITORY |
123 | 126 | logger.error(errMsg) |
124 | 127 | else: |
125 | | - logger.error("update could not be completed ('%s')" % re.sub(r"\W+", " ", stderr).strip()) |
| 128 | + logger.error("update could not be completed ('%s')" % re.sub(r"\W+", " ", output).strip()) |
126 | 129 |
|
127 | 130 | if not success: |
128 | 131 | if IS_WIN: |
|
0 commit comments