예제 #1
0
def isExecutable(path) :
  ret = False
  if Common.is_windows() :
    ret = path.endswith(".exe") or path.endswith(".bat") or or path.endswith(".ps1") or or path.endswith(".vbs")
  else :
    stinfo = os.stat(path)
    ret = stinfo.st_mode & S_IXUSR
  return ret
예제 #2
0
def insertToApps(path) :
  title = fs.getFileName(path)
  platform = "linux"
  if Common.is_windows() :
    platform = "windows"
  sql = f"INSERT INTO Apps VALUES(NULL, '{title}', '{path}', '', '{platform}', '', '', CURRENT_DATE())"
  mysql.execute(sql)
  return
예제 #3
0
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
예제 #4
0
#!/usr/bin/env python3

#  画像ファイルのサムネールを作成し、BINDATA テーブルに挿入する。
#  さらに、そのサムネールを Pictures または Videos テーブル、Album テーブルに、 Music テーブル関連付ける。
# (使用法) InsBINDATA3 画像ファイルのパス Picturesテーブルの対象id
# (バージョン) 1.1.0

from PIL import Image, ImageFilter
from Py365Lib import Common, FileSystem as fs, Text, MySQL
import os, math

# 定数定義
NEWSIZE = 64
if Common.is_windows():
    SAVEDIR = "c:/temp/"  # 注意:Windows では変更が必要
else:
    SAVEDIR = "/home/user/Pictures/Small"  # 注意:Windows では変更が必要
INSERT = "INSERT INTO BINDATA(`title`, `original`, `datatype`, `data`, `info`, `size`) VALUES('{0}', '{1}', '{2}', {3}, '', {4})"
UPDATE = "UPDATE {0} SET bindata = {1} WHERE id = {2}"


# バイナリーファイルをヘキサに変換する。
def bin2hex(filePath):
    buff = "0x"
    b = fs.readBinary(filePath)
    buff += b.hex()
    return buff


# サムネール画像を取得する。
def saveThumb(filePath):