コード例 #1
0
ファイル: InsVideos.py プロジェクト: makandat/gyunoya
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
            new_creator = ppath[lenpath - 2]
            sql = Text.format(UPDATE, new_creator, id)
            print(sql)
            client.execute(sql)
            print(sql)
        else:
            pass
    return


#
#  メイン
# ID の範囲を決める。
id_start = 1
id_end = 1000000
id_range = Common.readline("id の範囲 (nnnn-nnnn) を入力してください。(省略時はすべて)")
if id_range == "":
    Common.esc_print("yellow", "すべての id に対して実行します。(y/n)")
    a = Common.readline(">")
    if y != "y":
        Common.stop(9, "実行を中止しました。")
else:
    nn = Text.split('-', id_range)
    if len(nn) == 2:
        id_start = int(nn[0])
        id_end = int(nn[1])
    else:
        Common.stop(9, "範囲が正しくありません。実行を中止しました。")
    # Pictures テーブルからクエリーを行って対象のデータを得る。
    doChangeCreator()
    print("完了")
コード例 #3
0
ファイル: delete_ifiles.py プロジェクト: makandat/gyunoya
#!/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("終了。")
コード例 #4
0
# *************************************************
# この値が縮小画像のデフォルトサイズになる。
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)

a = Common.readline(
    f"{len(files)} 個のファイルを {SIZE} x {SIZE} 以内に縮小して {SAVEPATH} に保存します。(y/n)")
if a != 'y':
コード例 #5
0
    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':
        tableName = "Pictures"
コード例 #6
0
ファイル: html.py プロジェクト: makandat/gyunoya
      submit_click: () => {
        $.getJSON(URL, {"value":app.value}, (data) => {
          app.message = data;
        });
      }
    }
  });
</script>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
'''

if Common.count_args() == 0:
    filePath = Common.readline('HTMLファイルのパス名を入力してください。')
else:
    filePath = Common.args(0)

if Common.count_args() < 2:
    print("1: HTML5 のシンプルなページ")
    print("2: HTML5 のシンプルなページ + jQuery + Highlight.js")
    print("3: Bootstrap4 のページ")
    print("4: Bootstrap4 のページ + Highlight.js ")
    print("5: Vue.js のページ")
    pagen = int(Common.readline("番号入力 > "))
else:
    pagen = int(Common.args(1))

if pagen < 1 or pagen > 4:
    Common.stop(9, "番号が不正です。")
コード例 #7
0
ファイル: md5.py プロジェクト: makandat/gyunoya
#!/usr/bin/python3
import hashlib
from Py365Lib import Common
#  md5 の計算

print("md5 の計算")
if Common.count_args() == 0:
    instr = Common.readline('入力 > ')
else:
    instr = Common.args(0)
bstr = instr.encode()
m = hashlib.md5(bstr)
print(m.hexdigest())
コード例 #8
0
# ファイルにインタプリタを適用する。
def apply(fileName, interpreter):
    lines = fs.readLines(fileName)
    if lines[0].startswith('#!'):
        lines[0] = "#!" + interpreter + "\n"
        fs.writeLines(fileName, lines)
    else:
        print("Skiped: 行の先頭にインタプリタ指定が見当たりません。" + fileName)
    return


# 条件入力
fileName = ""
interpreterNo = 1
if Common.count_args() < 2:
    fileName = Common.readline("対象のファイル・フォルダを指定してください。> ")
    print(INTERPRETERS)
    interpreterNo = int(Common.readline("番号を選択してください。> "))
else:
    fileName = Common.args(0)
    interpreterNo = int(Common.args(1))

interpreterLines = INTERPRETERS.split('\n')
interpreter = Text.substring(interpreterLines[interpreterNo - 1], 3)
print(interpreter + " が " + fileName + " に適用されます。")
a = Common.readline("実行しますか? (y/n)")
if a != 'y':
    Common.stop(9, "実行が取り消されました。")

# インタプリタ適用
if fs.isFile(fileName):
コード例 #9
0
    return buff


# バイナリーファイル filePath をテーブル BINDATA に挿入する。
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


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

# MySQL クライアントを構築
mysql_client = MySQL.MySQL()
# データ挿入
last = insertBinaries(filePath)

print(f"BINDATA テーブルの id = {last} に挿入しました。")
コード例 #10
0
                        sf = "r" + Text.substring(ff[1], 2)
                        newname = folder + "/" + ff[0] + "_" + sf
                        fs.move(fpath, newname)
                        print("Renamed: " + newname)
                    else:
                        # 連続番号が3桁かつ300番台以上の場合はサポートしない(スキップする)
                        pass
                else:
                    # 連続番号が2桁の場合
                    #print("Passed: " + fpath)
                    pass
        else:
            #fs.move(fpath, fpath + ".jpg")
            print("Non image passed: " + fpath)
    return


#  スタート
if Common.count_args() == 0:
    folder = Common.readline("対象の画像フォルダを入力します。")
else:
    folder = Common.args(0)

if not fs.isDirectory(folder):
    Common.stop(1, folder + " は正しいディレクトリではありません。")

# 指定されたフォルダの画像ファイルを同じ長さにリネームする。
rename_files(folder)

print("正常終了。")