be more specific in standard output message as to whether or not the read file is same as remote file

This commit is contained in:
Bernardo Damele 2012-12-19 13:42:56 +00:00
parent 282aeb734f
commit 4f0f729982
2 changed files with 19 additions and 3 deletions

View File

@ -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))

View File

@ -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)