File size: 9,610 Bytes
12e1035 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
import os
import shutil
import time
import argparse
import requests
def get_daily_sentence(types=['a']):
params = {
'c': types
}
response = requests.get("https://v1.hitokoto.cn/", params=params)
if response.status_code == 200:
data = response.json()
return "\033[36m\033[4m" + data["hitokoto"] + "\033[0m"
else:
return " \033[36m\033[4m静待花开会有时,守得云开见月明\033[0m"
def ClearLike():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
path = "/mnt/workspace/Photo/Like"
if os.path.exists(path):
shutil.rmtree(path)
print(f"{path} 已删除")
else:
print(f"{path} 不存在")
def PackLike():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
path = "/mnt/workspace/Photo/Like"
zip_path = "/mnt/workspace/Like.zip"
if os.path.exists(path):
if os.path.exists(zip_path):
os.system(f"7z a {zip_path} {path} -y")
print("检测到旧的Like包存在,已经覆盖,已保存在根目录")
else:
os.system(f"7z a {zip_path} {path}")
print("打包完成,已保存在根目录,文件名为Like.zip")
else:
print(f"{path} 文件夹不存在")
def ClearUpscale():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
path = "/mnt/workspace/Photo/Upscale"
if os.path.exists(path):
shutil.rmtree(path)
print(f"{path} 已删除")
else:
print(f"{path} 不存在")
def PackUpscale():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
path = "/mnt/workspace/Photo/Upscale"
zip_path = "/mnt/workspace/Upscale.zip"
if os.path.exists(path):
if os.path.exists(zip_path):
os.system(f"7z a {zip_path} {path} -y")
print("检测到旧的Upscale包存在,已经覆盖,已保存在根目录")
else:
os.system(f"7z a {zip_path} {path}")
print("打包完成,已保存在根目录,文件名为Upscale.zip")
else:
print(f"{path} 文件夹不存在")
def ClearAll():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l'])
print(daily_sentence)
path = "/mnt/workspace/Photo/"
if os.path.exists(path):
for item in os.listdir(path):
item_path = os.path.join(path, item)
if os.path.isdir(item_path):
shutil.rmtree(item_path)
print(f"{path} 已清空")
else:
print(f"{path} 文件夹不存在")
def PackAll():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
path = "/mnt/workspace/Photo"
zip_path = "/mnt/workspace/Photo.zip"
if os.path.exists(path):
if os.path.exists(zip_path):
os.system(f"7z a {zip_path} {path} -y")
print("检测到旧的Photo包存在,已经覆盖,已保存在根目录")
else:
os.system(f"7z a {zip_path} {path}")
print("打包完成,已保存在根目录,文件名为Photo.zip")
else:
print(f"{path} 文件夹不存在")
def ClearLikeUpscale():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
path = "/mnt/workspace/Photo/Like_Upscale"
if os.path.exists(path):
shutil.rmtree(path)
print(f"{path} 已删除")
else:
print(f"{path} 不存在")
def PackLikeUpscale():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
path = "/mnt/workspace/Photo/Like_Upscale"
zip_path = "/mnt/workspace/Like_Upscale.zip"
if os.path.exists(path):
if os.path.exists(zip_path):
os.system(f"7z a {zip_path} {path} -y")
print("检测到旧的Like_Upscale包存在,已经覆盖,已保存在根目录")
else:
os.system(f"7z a {zip_path} {path}")
print("打包完成,已保存在根目录,文件名为Like_Upscale.zip")
else:
print(f"{path} 文件夹不存在\n")
print("请在SD界面-后期处理-批量处理文件夹中设置\n")
print("输入目录")
print("/mnt/workspace/Photo/Like\n")
print("输出目录")
print("/mnt/workspace/Photo/Like_Upscale\n")
def Cleartodaytxt2img():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
current_time = time.localtime()
formatted_time = time.strftime("%Y-%m-%d", current_time)
todaypath = f"/mnt/workspace/Photo/txt2img/{formatted_time}"
if os.path.exists(todaypath):
shutil.rmtree(todaypath)
print(f"{todaypath} 已删除")
else:
print(f"{todaypath} 不存在")
def Packtodaytxt2img():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
current_time = time.localtime()
formatted_time = time.strftime("%Y-%m-%d", current_time)
todaypath = f"/mnt/workspace/Photo/txt2img/{formatted_time}"
zip_path = f"/mnt/workspace/【文生图】{formatted_time}.zip"
if os.path.exists(todaypath):
if os.path.exists(zip_path):
os.system(f"7z a {zip_path} {todaypath} -y")
print(f"检测到旧的【文生图】{formatted_time}包存在,已经覆盖,已保存在根目录")
else:
os.system(f"7z a {zip_path} {todaypath}")
print(f"打包完成,已保存在根目录,文件名为【文生图】{formatted_time}.zip")
else:
print(f"{todaypath} 文件夹不存在")
def cleartodayimg2img():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
current_time = time.localtime()
formatted_time = time.strftime("%Y-%m-%d", current_time)
todaypath = f"/mnt/workspace/Photo/txt2img/{formatted_time}"
if os.path.exists(todaypath):
shutil.rmtree(todaypath)
print(f"{todaypath} 已删除")
else:
print(f"{todaypath} 不存在")
def Packtodayimg2img():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
current_time = time.localtime()
formatted_time = time.strftime("%Y-%m-%d", current_time)
todaypath = f"/mnt/workspace/Photo/img2img/{formatted_time}"
zip_path = f"/mnt/workspace/【图生图】{formatted_time}.zip"
if os.path.exists(todaypath):
if os.path.exists(zip_path):
os.system(f"7z a {zip_path} {todaypath} -y")
print(f"检测到旧的【图生图】{formatted_time}包存在,已经覆盖,已保存在根目录")
else:
os.system(f"7z a {zip_path} {todaypath}")
print(f"打包完成,已保存在根目录,文件名为【图生图】{formatted_time}.zip")
else:
print(f"{todaypath} 文件夹不存在")
def Clearoriginalimg2img():
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
print(daily_sentence)
path = f"/mnt/workspace/Photo/img2img/original"
if os.path.exists(path):
shutil.rmtree(path)
print(f"{path} 已删除")
else:
print(f"{path} 不存在")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Process some integers.")
parser.add_argument("-ClearLike", action="store_true", help="Clear Like folder")
parser.add_argument("-PackLike", action="store_true", help="Pack Like folder")
parser.add_argument("-ClearUpscale", action="store_true", help="Clear Upscale folder")
parser.add_argument("-PackUpscale", action="store_true", help="Pack Upscale folder")
parser.add_argument("-ClearAll", action="store_true", help="Clear All folder")
parser.add_argument("-PackAll", action="store_true", help="Pack All folder")
parser.add_argument("-ClearLikeUpscale", action="store_true", help="Clear Like_Upscale folder")
parser.add_argument("-PackLikeUpscale", action="store_true", help="Pack Like_Upscale folder")
parser.add_argument("-Cleartodaytxt2img", action="store_true", help="Clear todaytxt2img folder")
parser.add_argument("-Packtodaytxt2img", action="store_true", help="Pack todaytxt2img folder")
parser.add_argument("-Packtodayimg2img", action="store_true", help="Pack todayimg2img folder")
parser.add_argument("-Cleartodayimg2img", action="store_true", help="Clear todayimg2img folder")
parser.add_argument("-Clearoriginalimg2img", action="store_true", help="Pack Clearoriginalimg2img folder")
args = parser.parse_args()
if args.ClearLike:
ClearLike()
elif args.PackLike:
PackLike()
elif args.ClearUpscale:
ClearUpscale()
elif args.PackUpscale:
PackUpscale()
elif args.ClearAll:
ClearAll()
elif args.PackAll:
PackAll()
elif args.ClearLikeUpscale:
ClearLikeUpscale()
elif args.PackLikeUpscale:
PackLikeUpscale()
elif args.Cleartodaytxt2img:
Cleartodaytxt2img()
elif args.Packtodaytxt2img:
Packtodaytxt2img()
elif args.Packtodayimg2img:
Packtodayimg2img()
elif args.Cleartodayimg2img:
Cleartodayimg2img()
elif args.Clearoriginalimg2img:
Clearoriginalimg2img()
|