From 4f0f729982d70de53a900feabae25cf58e424a1c Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Wed, 19 Dec 2012 13:42:56 +0000 Subject: [PATCH] be more specific in standard output message as to whether or not the read file is same as remote file --- lib/core/dump.py | 11 ++++++++++- plugins/generic/filesystem.py | 11 +++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/core/dump.py b/lib/core/dump.py index b86168ab9..9578c5d08 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -19,6 +19,7 @@ from lib.core.common import isListLike from lib.core.common import normalizeUnicode from lib.core.common import openFile from lib.core.common import prioritySortColumns +from lib.core.common import randomInt from lib.core.common import safeCSValue from lib.core.common import unsafeSQLIdentificatorNaming from lib.core.data import conf @@ -34,6 +35,7 @@ from lib.core.settings import HTML_DUMP_CSS_STYLE from lib.core.settings import METADB_SUFFIX from lib.core.settings import TRIM_STDOUT_DUMP_SIZE from lib.core.settings import UNICODE_ENCODING +from thirdparty.magic import magic class Dump(object): """ @@ -63,7 +65,7 @@ class Dump(object): kb.dataOutputFlag = True def setOutputFile(self): - self._outputFile = "%s%slog" % (conf.outputPath, os.sep) + self._outputFile = "%s%sstdout" % (conf.outputPath, os.sep) try: self._outputFP = codecs.open(self._outputFile, "ab", UNICODE_ENCODING) except IOError, ex: @@ -476,6 +478,13 @@ class Dump(object): blank = " " * (maxlength - len(value)) self._write("| %s%s" % (value, blank), newline=False, console=console) + mimetype = magic.from_buffer(value, mime=True) + + if mimetype.startswith("application") or mimetype.startswith("image"): + singleFP = open("%s%s%s" % (dumpDbPath, os.sep, "%s-%d.bin" % (column, randomInt(8))), "wb") + singleFP.write(value.encode("utf8")) + singleFP.close() + if conf.dumpFormat == DUMP_FORMAT.CSV: if field == fields: dataToDumpFile(dumpFP, "%s" % safeCSValue(value)) diff --git a/plugins/generic/filesystem.py b/plugins/generic/filesystem.py index 98704220d..f8a7afb16 100644 --- a/plugins/generic/filesystem.py +++ b/plugins/generic/filesystem.py @@ -157,7 +157,7 @@ class Filesystem: if not output or output in ("y", "Y"): return self._checkFileLength(localFile, remoteFile, True) - return True + return None def nonStackedReadFile(self, remoteFile): errMsg = "'nonStackedReadFile' method must be defined " @@ -236,7 +236,14 @@ class Filesystem: if not Backend.isDbms(DBMS.PGSQL): self.cleanup(onlyFileTbl=True) - self.askCheckReadFile(remoteFilePath, remoteFile) + sameFile = self.askCheckReadFile(remoteFilePath, remoteFile) + + if sameFile is True: + remoteFilePath += " (same file)" + elif sameFile is False: + remoteFilePath += " (size differs from remote file)" + elif sameFile is None: + remoteFilePath += " (size not compared to remote file)" remoteFilePaths.append(remoteFilePath)