def insertBinaries(filePath): ext = fs.getExtension(filePath) size = fs.getFileSize(filePath) name = fs.getFileName(filePath) filePath = filePath.replace("\\", "/") hexa = bin2hex(filePath) sn = mysql_client.getValue("SELECT max(sn) FROM BINDATA") + 1 sql = Text.format(INSERT, name, filePath, ext, hexa, size, sn) mysql_client.execute(sql) lastId = mysql_client.getValue("SELECT max(id) FROM BINDATA") return lastId
def insertBinaries(filePath): INSERT = "INSERT INTO BINDATA(`title`, `original`, `datatype`, `data`, `info`, `size`) VALUES('{0}', '{1}', '{2}', {3}, '', {4})" ext = fs.getExtension(filePath) size = fs.getFileSize(filePath) fileName = fs.getFileName(filePath) filePath = filePath.replace("\\", "/") filePath = filePath.replace("'", "''") hexa = bin2hex(filePath) sql = Text.format(INSERT, fileName, filePath, ext, hexa, size) client = MySQL.MySQL() client.execute(sql) return
def insertBinaries(filePath, origin): ext = fs.getExtension(filePath) size = fs.getFileSize(filePath) parts = origin.split("/") n = len(parts) name = parts[n - 3] + " " + parts[n - 2] filePath = filePath.replace("\\", "/") filePath = filePath.replace("'", "''") hexa = bin2hex(filePath) sql = Text.format(INSERT, name, origin, ext, hexa, size) mysql_client.execute(sql) lastId = mysql_client.getValue("SELECT max(id) FROM BINDATA") return lastId
def getFileInfo(f): if Common.is_windows(): mode = "" owner = "" group = "" else: mode = "o{0:o}".format(fs.getAttr(f)) owner = fs.getOwner(f) group = fs.getGroup(f) dir_or_link = "" if fs.isDirectory(f): dir_or_link = "D" if fs.isLink(f): dir_or_link += "L" size = fs.getFileSize(f) last = fs.getLastWrite(f) filename = fs.getFileName(f) item = [mode, dir_or_link, owner, group, size, last, filename] return item