예제 #1
0
def main():
    print("** Videos テーブル用ビデオファイル一覧を作成または挿入する。**")
    # path 取得
    if Common.count_args() == 0:
        Common.stop(1, "使用方法: python3 InsVideos.py path insert")
    path = Common.args(0)
    # print/insert オプション取得
    insoption = False
    if Common.count_args() == 2:
        insoption = True
    # 確認
    if not insoption:
        print(f"Path = {path}, Videos テーブルに挿入 = {insoption}")
        a = Common.readline("Confirm (Y/N) > ")
        if Text.tolower(a) != 'y':
            Common.stop(2, "実行を中止しました。")
    else:
        pass
    # ビデオファイル一覧を取得する。
    vfiles = getVideoFiles(path)
    # INSERT 文を作成する。
    sql = "INSERT INTO Videos VALUES"
    for p in vfiles:
        p = p.replace("'", "''")
        fileName = FileSystem.getFileName(p)
        title = Text.left(fileName, len(fileName) - 4)
        sql += f"(NULL, '0', '{title}', '{p}', '', '', '', '', 0, 0, 0, 0, 0),\n"
        print(p)
    sql = Text.left(sql, len(sql) - 2) + ";"
    if not insoption:
        print(sql)
    if insoption:
        # INSERT 文を実行する。
        try:
            mysql = MySQL.MySQL(UID, PWD, UID)
            mysql.execute(sql)
            # 終了メッセージ
            if not insoption:
                print("正常に終了しました。")
        except Error as e:
            Common.stop("MySQL のエラーにより終了。接続条件やSQL をチェックしてください。" + e.message)
    return
예제 #2
0
#!/usr/bin/env python3

#  YJFX_Asset テーブルにデータを挿入する。
from Py365Lib import Common, MySQL

# パラメータ確認
if Common.count_args() < 3:
    Common.stop(9, "Usage: InsAsset.py date asset loss", Common.ESC_FG_YELLOW)

date = Common.args(0)
asset = Common.args(1)
loss = Common.args(2)

sql = f"INSERT INTO YJFX_Asset VALUES(null, '{date}', {asset}, {loss}, '')"

mysql = MySQL.MySQL()
mysql.execute(sql)

sql = "SELECT * FROM VW_YJFX_Asset"
result = mysql.query(sql)

for row in result:
    print(row)

print("Done.")
예제 #3
0
#  (注意) ファイル一覧は UTF-8、json ファイルは SJIS で作成する。
#  json ファイルの例
'''
{
  "album":165
  "media":"HD-LLU3",
  "series":"アニソン",
  "mark":"アニメ",
  "info":""
}
'''
from Py365Lib import Common, FileSystem as fs, MySQL

# START
# パラメータ確認
if Common.count_args() < 1 :
  Common.stop("Usage : Ins_VideosSQL.py filelist [json]")
filelist = Common.args(0)
album = 0
media = "media"
series = "series"
mark = "mark"
info = "info"
if Common.count_args() >= 2 :
  json = fs.readJson(Common.args(1))
  album = json["album"]
  media = json["media"]
  series = json["series"]
  mark = json["mark"]
  info = json["info"]
else :
예제 #4
0
#!/usr/bin/env python3
#  再帰的に中間ファイルを削除する。
from Py365Lib import Common, FileSystem as fs
import os

# 中間ファイルの拡張子
iexts = (".obj", ".res", ".resw", ".pdb", ".pch", ".rc", ".rc2")

# パラメータを得る。
print("== 再帰的に中間ファイルを削除する。==")
# 対象のフォルダを得る。
if Common.count_args() == 0 :
  Common.stop(9, "フォルダを指定してください。")
folder = Common.args(0)
a = Common.readline(folder + "に対して再帰的に中間ファイルを削除します。よろしいですか? (y/n)")
if a != "y" :
  Common.stop(1, "実行を中止しました。")

# 実行する。
files = fs.listFilesRecursively(folder, asstr=True)
for f in files:
  ext = fs.getExtension(f)
  for e in iexts:
    if ext == e :
      print("削除: " + f)
      os.remove(f)
    else :
      pass
print("終了。")
예제 #5
0
    return (nw, nh)


# *************************************************
# この値が縮小画像のデフォルトサイズになる。
SIZE = 1600
#SIZE = 1920
#SIZE = 2560
# 縮小画像ファイルのデフォルト保存先
SAVEPATH = 'C:/Temp/small/'
# True なら JPEG で保存
JPEG = True
# *************************************************

# ここから開始
if Common.count_args() == 0:
    print("画像縮小専用 Usage: python smalls.py folder size save_path")
    folder = Common.readline(
        "画像ファイルの存在するフォルダパスを入力します。(Enter のみで中止。ファイルサイズと保存先はデフォルト値)> ")
    if folder == "":
        Common.stop("処理を中止しました。")
else:
    folder = Common.args(0)
    if Common.count_args() >= 2:
        SIZE = int(Common.args(1))
    if Common.count_args() >= 3:
        SAVEPATH = Common.args(2)

# 指定されたフォルダ内の画像ファイル一覧を得る。
files = fs.listFiles(folder)
예제 #6
0
    sql = Text.format(INSERT, name, origin, ext, hexa, size)
    mysql_client.execute(sql)
    lastId = mysql_client.getValue("SELECT max(id) FROM BINDATA")
    return lastId


# Pictures or Videos or Album テーブルを更新する。
def updateTable(tableName, bid, pid):
    sql = UPDATE.format(tableName, bid, pid)
    mysql_client.execute(sql)
    return


#  Start up
# パラメータ確認・取得
if Common.count_args() == 0:
    filePath = Common.readline("画像ファイルのパスを入力します。> ")
else:
    filePath = Common.args(0)

if Common.count_args() == 1:
    pid = Common.readline("Pictures テーブルの対象 id を入力します。> ")
else:
    pid = Common.args(1)

if Common.count_args() == 2:
    tableName = "Pictures"
else:
    if Common.args(2) == "V":
        tableName = "Videos"
    elif Common.args(2) == 'P':
예제 #7
0
파일: tail.py 프로젝트: makandat/gyunoya
#!/usr/bin/env python3
#  tail filePath [lines]
from Py365Lib import Common, FileSystem as fs
from collections import deque

if Common.count_args() < 1:
    Common.stop(9, "Usage: tail filePath [lines] [encoding]")

filePath = Common.args(0)

if Common.count_args() > 1:
    n = int(Common.args(1))
else:
    n = 20

if Common.count_args() > 2:
    code = Common.args(2)
else:
    code = "utf-8"

fifo = deque(maxlen=n)
with open(filePath, mode="r", encoding=code) as f:
    line = f.readline()
    while line:
        fifo.append(line)
        line = f.readline()

while True:
    if len(fifo) > 0:
        l = fifo.popleft()
        print(l, end="")
예제 #8
0
    sql = Text.format(INSERT, name, origin, ext, hexa, size)
    mysql_client.execute(sql)
    lastId = mysql_client.getValue("SELECT max(id) FROM BINDATA")
    return lastId


# Pictures or Videos or Album テーブルを更新する。
def updateTable(tableName, bid, pid):
    sql = UPDATE.format(tableName, bid, pid)
    mysql_client.execute(sql)
    return


#  Start up
# パラメータ確認・取得
if Common.count_args() == 0:
    filePath = Common.readline("画像ファイルのパスを入力します。> ")
else:
    filePath = Common.args(0)

nargs = Common.count_args()

if nargs == 1:
    pid = Common.readline("Pictures テーブルの対象 id を入力します。> ")
    nargs = 2
else:
    pid = Common.args(1)

if nargs == 2:
    tableName = "Pictures"
else: