Exemple #1
0
def updateDate(mysql, id) :
  # id から path を得る。
  path = mysql.getValue(f"SELECT path FROM Pictures WHERE id={id}")
  if path == None :
    print(f"エラー: id = {id} のデータがありません。")
    return
  print("path = ", path)

  # ディレクトリ内のファイルを検索して、一番新しいファイルの日付を得る。
  #files = fs.listFiles(path, "*", True)
  files = os.listdir(path.encode('utf-8'))
  if len(files) == 0 :
    print("エラー: ファイルが見つかりません。")
    return
  time0 = fs.getLastWrite(path + "/" + files[0].decode('utf-8'))
  pathlast = files[0].decode('utf-8')
  for f in files :
    time1 = fs.getLastWrite(path + "/" + f.decode('utf-8'))
    if time1 < time0 :
      time0 = time1
  date0 = time0[0:10]
  print(date0)

  # Pictures テーブルの当該レコードの日付(date)を更新する。
  sql = f"UPDATE Pictures SET `date`='{date0}' WHERE id={id}"
  print(sql)
  mysql.execute(sql)
  return
Exemple #2
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