Upload files to "/"

This commit is contained in:
Hitmare 2023-11-11 19:17:59 +00:00
parent 6865e06a2e
commit 0c948e72e4
2 changed files with 428 additions and 426 deletions

View File

@ -23,7 +23,7 @@ def scanfolder(path: str) -> list:
os.remove(f"{modelfolder}{modelname}.civitai.info") os.remove(f"{modelfolder}{modelname}.civitai.info")
sideload = True sideload = True
else: else:
with open(f"{modelfolder}{modelname}.civitai.info", "r") as f: with open(f"{modelfolder}{modelname}.civitai.info", "r", encoding='utf-8') as f:
#fstring = "dd" #fstring = "dd"
print("Reading", modelfolder, modelfile) print("Reading", modelfolder, modelfile)
modelinfoarray = json.load(f) modelinfoarray = json.load(f)
@ -63,7 +63,7 @@ def scanfolder(path: str) -> list:
modelid = modelinfoarray.get('modelId') modelid = modelinfoarray.get('modelId')
civitailist.append(modelid) civitailist.append(modelid)
print(f"Creating {modelfolder}{modelname}.civitai.info for future use") print(f"Creating {modelfolder}{modelname}.civitai.info for future use")
modelinfofile = open(f"{modelfolder}{modelname}.civitai.info", "w") modelinfofile = open(f"{modelfolder}{modelname}.civitai.info", "w", encoding='utf-8')
modelinfofile.write(resp.data.decode('utf-8')) modelinfofile.write(resp.data.decode('utf-8'))
modelinfofile.close() modelinfofile.close()
@ -81,12 +81,12 @@ def scanfolder(path: str) -> list:
def scanall(): def scanall():
erislist = {} erislist = {}
erislist['lora'] = {} erislist['lora'] = {}
result = scanfolder("./models/lora/") result = scanfolder("./models/Lora/")
erislist['lora']['civitai'] = result[0] erislist['lora']['civitai'] = result[0]
erislist['lora']['sideload'] = result[1] erislist['lora']['sideload'] = result[1]
erislist['sd'] = {} erislist['sd'] = {}
result = scanfolder("./models/stable-diffusion/") result = scanfolder("./models/Stable-diffusion/")
erislist['sd']['civitai'] = result[0] erislist['sd']['civitai'] = result[0]
erislist['sd']['sideload'] = result[1] erislist['sd']['sideload'] = result[1]

View File

@ -1,422 +1,424 @@
import json import json
import urllib3 import urllib3
import urllib.request #import urllib.request
import os import os
import cgi import cgi
from pathlib import Path from pathlib import Path
import argparse import argparse
import string import string
#import getpass #import getpass
#print("Env thinks the user is [%s]" % (os.getlogin())) #print("Env thinks the user is [%s]" % (os.getlogin()))
#print("Effective user is [%s]" % (getpass.getuser())) #print("Effective user is [%s]" % (getpass.getuser()))
import erisscan import erisscan
def filter_str(s: str) -> str: def filter_str(s: str) -> str:
return "".join(filter(lambda x: x in string.printable, s)) return "".join(filter(lambda x: x in string.printable, s))
def downloadcivitai(modelid: str, type: str, image: bool) -> bool:
def downloadcivitai(modelid: str, type: str, image: bool) -> bool:
match type:
match type: case "lora":
case "lora": dlpath = f"./models/Lora/"
dlpath = f"./models/Lora/" case "sd":
case "sd": dlpath = f"./models/Stable-diffusion/"
dlpath = f"./models/Stable-diffusion/" case "emb":
case "emb": dlpath = f"./embeddings/"
dlpath = f"./embeddings/"
http = urllib3.PoolManager()
http = urllib3.PoolManager() urlid = f"https://civitai.com/api/v1/models/{modelid}"
urlid = f"https://civitai.com/api/v1/models/{modelid}" resp = http.request('GET', urlid)
resp = http.request('GET', urlid) modelarray = json.loads(resp.data.decode('utf-8'))
modelarray = json.loads(resp.data.decode('utf-8')) modelsha256 = modelarray.get('modelVersions')[0].get('files')[0].get('hashes').get("SHA256")
modelsha256 = modelarray.get('modelVersions')[0].get('files')[0].get('hashes').get("SHA256") urlhash = f"https://civitai.com/api/v1/model-versions/by-hash/{modelsha256}"
urlhash = f"https://civitai.com/api/v1/model-versions/by-hash/{modelsha256}" modelimageurl = modelarray.get('modelVersions')[0].get('images')[0].get('url')
modelimageurl = modelarray.get('modelVersions')[0].get('images')[0].get('url')
modelfilename = modelarray.get('modelVersions')[0].get('files')[0].get('name') modelfilename = modelarray.get('modelVersions')[0].get('files')[0].get('name')
#modelfilesize = int(modelarray.get('modelVersions')[0].get('files')[0].get('sizeKB')) modelfilename = filter_str(modelfilename)
modelname = Path(modelfilename).stem #modelfilesize = int(modelarray.get('modelVersions')[0].get('files')[0].get('sizeKB'))
modelfileurl = modelarray.get('modelVersions')[0].get('files')[0].get('downloadUrl') modelname = Path(modelfilename).stem
#modeldisplayname = modelarray.get('name') modelfileurl = modelarray.get('modelVersions')[0].get('files')[0].get('downloadUrl')
#trainedwords = modelarray.get('modelVersions')[0].get('trainedWords') #modeldisplayname = modelarray.get('name')
#trainedwords = modelarray.get('modelVersions')[0].get('trainedWords')
modelimagename = [f"{modelname}.preview.jpg", f"{modelname}.preview.jpeg", f"{modelname}.preview.png"] modelimagename = [f"{modelname}.preview.jpg", f"{modelname}.preview.jpeg", f"{modelname}.preview.png"]
#modelimagename = "" #modelimagename = ""
modelinfofile = f"{modelname}.civitai.info" modelinfofile = f"{modelname}.civitai.info"
def downloadmodel(url: str, dlpath: str) -> bool: def downloadmodel(url: str, dlpath: str) -> bool:
print(f"Download {modelfilename} to {dlpath}") print(f"Download {modelfilename} to {dlpath}")
dlrequest = http.request('GET', url, preload_content=False) dlrequest = http.request('GET', url, preload_content=False)
filesize = dlrequest.getheader('content-length') filesize = dlrequest.getheader('content-length')
contentdis = dlrequest.getheader('Content-Disposition') contentdis = dlrequest.getheader('Content-Disposition')
try: try:
type, filename = cgi.parse_header(contentdis) type, filename = cgi.parse_header(contentdis)
#print("Found file", dict(filename).get('filename')) #print("Found file", dict(filename).get('filename'))
filename = dict(filename).get('filename') filename = dict(filename).get('filename')
#filename = filename.encode('utf-8') filename = filter_str(filename)
#filename = filter_str(filename) except Exception as e:
except Exception as e: print("Cannot get filename", e)
print("Cannot get filename", e) if filesize:
if filesize: filesize = int(filesize)
filesize = int(filesize) blocksize = max(4096, filesize//100)
blocksize = max(4096, filesize//100) print(f"Filesize: {filesize//1024} kB | {filesize//1024//1024} MB")
print(f"Filesize: {filesize//1024} kB | {filesize//1024//1024} MB") else:
else: blocksize = 10000
blocksize = 10000 #with open(f"{dlpath}{filename}", 'wb') as out:
#with open(f"{dlpath}{filename}", 'wb') as out: with open(Path(dlpath) / filename, 'wb') as out:
with open(Path(dlpath) / filename, 'wb') as out: size = 0
size = 0 while True:
while True: data = dlrequest.read(blocksize)
data = dlrequest.read(blocksize) if not data:
if not data: break
break size += len(data)
size += len(data) out.write(data)
out.write(data) if filesize:
if filesize: Percent = int((size / filesize)*100)
Percent = int((size / filesize)*100) if Percent == 100:
if Percent == 100: print(f"Download: {Percent}%")
print(f"Download: {Percent}%") else:
else: print(f"Download: {Percent}%", end='\r')
print(f"Download: {Percent}%", end='\r') dlrequest.release_conn()
dlrequest.release_conn()
def downloadimage(url: str, dlpath: str) -> tuple((bool, str)):
def downloadimage(url: str, dlpath: str) -> bool: print(f"Download Image for {modelfilename}")
print(f"Download Image for {modelfilename}") imagerequest = http.request('GET', url, preload_content=False)
imagerequest = http.request('GET', url, preload_content=False) #path = f"{os.getcwd()}/models/Loras/"
#path = f"{os.getcwd()}/models/Loras/" filesize = imagerequest.getheader('content-length')
filesize = imagerequest.getheader('content-length') contentdis = imagerequest.getheader('Content-Disposition')
#contentdis = imagerequest.getheader('Content-Disposition') if contentdis == None:
#type, filename = cgi.parse_header(contentdis) filename = f"{Path(modelfilename).stem}.preview.png"
filename = f"{Path(modelfilename).stem}.preview{Path(filename).suffix}" else:
global modelimagename #print("Content", contentdis)
modelimagename = filename type, filename = cgi.parse_header(contentdis)
#print(filename['filename']) filename = dict(filename).get('filename')
if filesize: filename = f"{Path(modelfilename).stem}.preview{Path(filename).suffix}"
filesize = int(filesize) #print(filename['filename'])
blocksize = max(4096, filesize//100) if filesize:
print(f"Filesize: {filesize//1024} kB | {filesize//1024//1024} MB") filesize = int(filesize)
else: blocksize = max(4096, filesize//100)
blocksize = 1000 print(f"Filesize: {filesize//1024} kB | {filesize//1024//1024} MB")
with open(f"{dlpath}{filename}", 'wb') as out: else:
size = 0 blocksize = 1000
while True: with open(f"{dlpath}{filename}", 'wb') as out:
data = imagerequest.read(blocksize) size = 0
if not data: while True:
break data = imagerequest.read(blocksize)
size += len(data) if not data:
out.write(data) break
if filesize: size += len(data)
Percent = int((size / filesize)*100) out.write(data)
if Percent == 100: if filesize:
print(f"Download: {Percent}%") Percent = int((size / filesize)*100)
else: if Percent == 100:
print(f"Download: {Percent}%", end='\r') print(f"Download: {Percent}%")
imagerequest.release_conn() else:
print(f"Download: {Percent}%", end='\r')
def downloadinfo(url: str, dlfullpath: str) -> bool: imagerequest.release_conn()
print(f"Download Infofile for {modelfilename}") return tuple((True, filename))
resp = http.request('GET', url)
infofile = open(f"{dlfullpath}", "w") def downloadinfo(url: str, dlfullpath: str) -> bool:
infofile.write(resp.data.decode('utf-8')) print(f"Download Infofile for {modelfilename}")
infofile.close() resp = http.request('GET', url)
infofile = open(f"{dlfullpath}", "w", encoding='utf-8')
# download Model file infofile.write(resp.data.decode('utf-8'))
try: infofile.close()
if not os.path.exists(f"{dlpath}{modelfilename}"):
downloadmodel(modelfileurl, dlpath) # download Model file
else: try:
print(f"{modelfilename} already exist, skip download") if not os.path.exists(f"{dlpath}{modelfilename}"):
except Exception as e: downloadmodel(modelfileurl, dlpath)
print(e) else:
finally: print(f"{modelfilename} already exist, skip download")
if not os.path.exists(f"{dlpath}{modelfilename}"): except Exception as e:
print(f"{modelfilename} could not be saved, abort.") print(e)
return False finally:
# download Preview image, if not disabled if not os.path.exists(f"{dlpath}{modelfilename}"):
if image: print(f"{modelfilename} could not be saved, abort.")
try: return False
if os.path.exists(f"{dlpath}{modelimagename[0]}") == False and os.path.exists(f"{dlpath}{modelimagename[1]}") == False and os.path.exists(f"{dlpath}{modelimagename[2]}") == False: # download Preview image, if not disabled
downloadimage(modelimageurl, dlpath) if image:
else: try:
print(f"Preview Image for {modelfilename} already exist, skip download") if os.path.exists(f"{dlpath}{modelimagename[0]}") == False and os.path.exists(f"{dlpath}{modelimagename[1]}") == False and os.path.exists(f"{dlpath}{modelimagename[2]}") == False:
dlimage = downloadimage(modelimageurl, dlpath)
except Exception as e: else:
print(e) print(f"Preview Image for {modelfilename} already exist, skip download")
finally:
if isinstance(modelfilename, str): except Exception as e:
if not os.path.exists(f"{dlpath}{modelimagename}"): print(e)
print(f"{modelfilename} could not be saved, continue.") finally:
# save infofile if isinstance(dlimage[1], str):
try: if not os.path.exists(f"{dlpath}{dlimage[1]}"):
if not os.path.exists(f"{dlpath}{modelinfofile}"): print(f"{dlimage[1]} could not be saved, continue.")
downloadinfo(urlhash, f"{dlpath}{modelinfofile}") # save infofile
else: try:
print(f"{modelinfofile} already exist, skip creation") if not os.path.exists(f"{dlpath}{modelinfofile}"):
except Exception as e: downloadinfo(urlhash, f"{dlpath}{modelinfofile}")
print(e) else:
finally: print(f"{modelinfofile} already exist, skip creation")
if not os.path.exists(f"{dlpath}{modelinfofile}"): except Exception as e:
print(f"{modelinfofile} could not be created, abort.") print(e)
return False finally:
return True if not os.path.exists(f"{dlpath}{modelinfofile}"):
print(f"{modelinfofile} could not be created, abort.")
# ______________________________________________________________________ return False
return True
def downloadsideload(name: str, modeltype: str) -> bool:
sideloadserver = f"https://eris.hitmare.me/eris/{modeltype}/" # ______________________________________________________________________
match modeltype: def downloadsideload(name: str, modeltype: str) -> bool:
case "lora": sideloadserver = f"https://eris.hitmare.me/eris/{modeltype}/"
dlpath = "./models/lora/"
case "sd": match modeltype:
dlpath = "./models/stable-diffusion/" case "lora":
case "emb": dlpath = "./models/Lora/"
dlpath = "./embeddings/" case "sd":
dlpath = "./models/Stable-diffusion/"
http = urllib3.PoolManager() case "emb":
url = f"{sideloadserver}{name}" dlpath = "./embeddings/"
try:
print(f"Download {name}") http = urllib3.PoolManager()
dlrequest = http.request('GET', url, preload_content=False) url = f"{sideloadserver}{name}"
try:
if not int(dlrequest.status) == 200: print(f"Download {name}")
print(f"File {name} not found") dlrequest = http.request('GET', url, preload_content=False)
return False
if not int(dlrequest.status) == 200:
filesize = dlrequest.getheader('content-length') print(f"File {name} not found")
#print(filesize) return False
#contentdis = dlrequest.getheader('Content-Disposition')
#type, filename = cgi.parse_header(contentdis) filesize = dlrequest.getheader('content-length')
filename = name #print(filesize)
if filesize: #contentdis = dlrequest.getheader('Content-Disposition')
filesize = int(filesize) #type, filename = cgi.parse_header(contentdis)
blocksize = max(4096, filesize//100) filename = name
print(f"Filesize: {filesize//1024} kB | {filesize//1024//1024} MB") if filesize:
else: filesize = int(filesize)
blocksize = 10000 blocksize = max(4096, filesize//100)
with open(f"{dlpath}{filename}", 'wb') as out: print(f"Filesize: {filesize//1024} kB | {filesize//1024//1024} MB")
size = 0 else:
while True: blocksize = 10000
data = dlrequest.read(blocksize) with open(f"{dlpath}{filename}", 'wb') as out:
if not data: size = 0
break while True:
size += len(data) data = dlrequest.read(blocksize)
out.write(data) if not data:
if filesize: break
Percent = int((size / filesize)*100) size += len(data)
if Percent == 100: out.write(data)
print(f"Download: {Percent}%") if filesize:
else: Percent = int((size / filesize)*100)
print(f"Download: {Percent}%", end='\r') if Percent == 100:
print(f"Downloaded {dlpath}{filename}") print(f"Download: {Percent}%")
dlrequest.release_conn() else:
return True print(f"Download: {Percent}%", end='\r')
except Exception as e: print(f"Downloaded {dlpath}{filename}")
print(name, "not found on Sideloadserver", " | Python Error:" ,e) dlrequest.release_conn()
return False return True
except Exception as e:
print(name, "not found on Sideloadserver", " | Python Error:" ,e)
return False
# ______________________________________________________________________
# check current status of online and local lora
def checkcivitai(locallist: list, erislist: list) -> tuple:
#print("Check Civitai") # ______________________________________________________________________
#url = "https://eris.hitmare.me/lora.txt" # check current status of online and local lora
erismodels = erislist def checkcivitai(locallist: list, erislist: list) -> tuple:
localmodels = locallist #print("Check Civitai")
missingmodels = set() #url = "https://eris.hitmare.me/lora.txt"
additionalmodels = set() erismodels = erislist
savedmodels = set() localmodels = locallist
# check online list against local list missingmodels = set()
for loraid in erismodels: additionalmodels = set()
if not loraid in localmodels: savedmodels = set()
missingmodels.add(loraid) # check online list against local list
else: for loraid in erismodels:
savedmodels.add(loraid) if not loraid in localmodels:
missingmodels.add(loraid)
# check local list against online list else:
for loraid in localmodels: savedmodels.add(loraid)
if not loraid in erismodels:
additionalmodels.add(loraid) # check local list against online list
for loraid in localmodels:
return tuple((missingmodels, additionalmodels, savedmodels)) if not loraid in erismodels:
additionalmodels.add(loraid)
def checksideload(locallist: list, erislist: list) -> tuple: return tuple((missingmodels, additionalmodels, savedmodels))
#print("Check Sideload")
#url = "https://eris.hitmare.me/lora.txt"
erismodels = erislist def checksideload(locallist: list, erislist: list) -> tuple:
localmodels = locallist #print("Check Sideload")
missingmodels = set() #url = "https://eris.hitmare.me/lora.txt"
additionalmodels = set() erismodels = erislist
savedmodels = set() localmodels = locallist
# check online list against local list missingmodels = set()
for loraid in erismodels: additionalmodels = set()
if not loraid in localmodels: savedmodels = set()
missingmodels.add(loraid) # check online list against local list
else: for loraid in erismodels:
savedmodels.add(loraid) if not loraid in localmodels:
missingmodels.add(loraid)
# check local list against online list else:
for loraid in localmodels: savedmodels.add(loraid)
if not loraid in erismodels:
additionalmodels.add(loraid) # check local list against online list
for loraid in localmodels:
return tuple((missingmodels, additionalmodels, savedmodels)) if not loraid in erismodels:
additionalmodels.add(loraid)
def deleteFiles(nameid: str, modeltype: str, localfile: bool = False) -> bool:
match modeltype: return tuple((missingmodels, additionalmodels, savedmodels))
case "lora":
dlpath = "./models/lora/" def deleteFiles(nameid: str, modeltype: str, localfile: bool = False) -> bool:
case "sd": match modeltype:
dlpath = "./models/stable-diffusion/" case "lora":
case "emb": dlpath = "./models/Lora/"
dlpath = "./embeddings/" case "sd":
dlpath = "./models/Stable-diffusion/"
try: case "emb":
if localfile: dlpath = "./embeddings/"
modelfilename = nameid
else: try:
http = urllib3.PoolManager() if localfile:
urlid = f"https://civitai.com/api/v1/models/{nameid}" modelfilename = nameid
resp = http.request('GET', urlid) else:
modelarray = json.loads(resp.data.decode('utf-8')) http = urllib3.PoolManager()
modelfilename = modelarray.get('modelVersions')[0].get('files')[0].get('name') urlid = f"https://civitai.com/api/v1/models/{nameid}"
resp = http.request('GET', urlid)
modelfiles = os.listdir(dlpath) modelarray = json.loads(resp.data.decode('utf-8'))
for modelfile in modelfiles: modelfilename = modelarray.get('modelVersions')[0].get('files')[0].get('name')
if Path(modelfile).stem == Path(modelfilename).stem:
os.remove(f"{dlpath}{modelfile}") modelfiles = os.listdir(dlpath)
return True for modelfile in modelfiles:
except Exception as e: if Path(modelfile).stem == Path(modelfilename).stem:
print(f"Could not delete {nameid}. Error: {e}") os.remove(f"{dlpath}{modelfile}")
return False return True
except Exception as e:
parser = argparse.ArgumentParser( print(f"Could not delete {nameid}. Error: {e}")
prog='Eris File Updater', return False
description='Updates Lora, Embeddings and Stable-diffusion Models',
epilog='Thanks for being a part of the Eris Bot ^-^') parser = argparse.ArgumentParser(
prog='Eris File Updater',
parser.add_argument('-si', '--skipimage', help=r"Skips the download of the preview images, Applies to all Model Types", action="store_true") description='Updates Lora, Embeddings and Stable-diffusion Models',
parser.add_argument('-sl', '--skiplora', help=r"Skips check of lora models", action="store_true") epilog='Thanks for being a part of the Eris Bot ^-^')
parser.add_argument('-ss', '--skipsdmodel', help=r"Skips check of stable-diffusion models", action="store_true")
parser.add_argument('-se', '--skipemb', help=r"Skips check of embedding models", action="store_true") parser.add_argument('-si', '--skipimage', help=r"Skips the download of the preview images, Applies to all Model Types", action="store_true")
parser.add_argument('-c', '--cleanup', help=r"Deletes any models that are locally but not on the eris model list. Affected by Skip Triggers", action="store_true") parser.add_argument('-sl', '--skiplora', help=r"Skips check of lora models", action="store_true")
parser.add_argument('-ss', '--skipsdmodel', help=r"Skips check of stable-diffusion models", action="store_true")
args = parser.parse_args() parser.add_argument('-se', '--skipemb', help=r"Skips check of embedding models", action="store_true")
parser.add_argument('-c', '--cleanup', help=r"Deletes any models that are locally but not on the eris model list. Affected by Skip Triggers", action="store_true")
if not os.path.exists("./eris.json"):
# start scan python or exit args = parser.parse_args()
#print("Please run the erisscan bat/sh file first")
#exit() if not os.path.exists("./eris.json"):
print("No eris.json file found. Starting scan ...") # start scan python or exit
erisscan.scanall() #print("Please run the erisscan bat/sh file first")
#exit()
print("No eris.json file found. Starting scan ...")
# get the eris list from the web and local erisscan.scanall()
http = urllib3.PoolManager()
#erisurl = "https://eris.hitmare.me/eris.json"
erisurl = "https://git.foxo.me/Hitmare/Eris-Update-script/src/branch/main/eris.json" # get the eris list from the web and local
resp = http.request('GET', erisurl) http = urllib3.PoolManager()
erisremote = json.loads(resp.data.decode('utf-8')) erisurl = "https://eris.hitmare.me/eris.json"
erislocal = json.load(open("./eris.json", "r")) resp = http.request('GET', erisurl)
erisremote = json.loads(resp.data.decode('utf-8'))
if args.skipimage: erislocal = json.load(open("./eris.json", "r"))
dlimage = False
else: if args.skipimage:
dlimage = True dlimage = False
else:
if args.skiplora: dlimage = True
print("Skip Lora Model check")
else: if args.skiplora:
lorastate = checkcivitai(erislocal.get('lora')['civitai'], erisremote.get('lora')['civitai']) print("Skip Lora Model check")
if len(lorastate[0]) > 0 : else:
print(f"Missing lora ids: {lorastate[0]}") lorastate = checkcivitai(erislocal.get('lora')['civitai'], erisremote.get('lora')['civitai'])
for lora in lorastate[0]: if len(lorastate[0]) > 0 :
if downloadcivitai(lora, 'lora', dlimage): print(f"Missing lora ids: {lorastate[0]}")
erislocal.get('lora')['civitai'].append(lora) for lora in lorastate[0]:
lorasideloadstate = checksideload(erislocal.get('lora')['sideload'], erisremote.get('lora')['sideload']) if downloadcivitai(lora, 'lora', dlimage):
if len(lorasideloadstate[0]) > 0 : erislocal.get('lora')['civitai'].append(lora)
print(f"Missing lora files: {lorasideloadstate[0]}") lorasideloadstate = checksideload(erislocal.get('lora')['sideload'], erisremote.get('lora')['sideload'])
for lora in lorasideloadstate[0]: if len(lorasideloadstate[0]) > 0 :
if downloadsideload(lora, 'lora'): print(f"Missing lora files: {lorasideloadstate[0]}")
erislocal.get('lora')['sideload'].append(lora) for lora in lorasideloadstate[0]:
if args.cleanup: if downloadsideload(lora, 'lora'):
if len(lorastate[1]) > 0: erislocal.get('lora')['sideload'].append(lora)
print("Additional CivitAI lora ids:", lorastate[1]) if args.cleanup:
for dellora in lorastate[1]: if len(lorastate[1]) > 0:
if deleteFiles(dellora, 'lora'): print("Additional CivitAI lora ids:", lorastate[1])
erislocal.get('lora')['civitai'].remove(dellora) for dellora in lorastate[1]:
if len(lorasideloadstate[1]) > 0: if deleteFiles(dellora, 'lora'):
print("Additional CivitAI lora files:", lorastate[1]) erislocal.get('lora')['civitai'].remove(dellora)
for delslora in lorasideloadstate[1]: if len(lorasideloadstate[1]) > 0:
if deleteFiles(delslora, 'lora', True): print("Additional CivitAI lora files:", lorastate[1])
erislocal.get('lora')['sideload'].remove(delslora) for delslora in lorasideloadstate[1]:
#print(len(lorastate[1])) if deleteFiles(delslora, 'lora', True):
if args.skipsdmodel: erislocal.get('lora')['sideload'].remove(delslora)
print("Skip Stable-Diffusion Model check") #print(len(lorastate[1]))
else: if args.skipsdmodel:
sdstate = checkcivitai(erislocal.get('sd')['civitai'], erisremote.get('sd')['civitai']) print("Skip Stable-Diffusion Model check")
if len(sdstate[0]) > 0 : else:
print(f"Missing CivitAI stable-diffusion ids: {sdstate[0]}") sdstate = checkcivitai(erislocal.get('sd')['civitai'], erisremote.get('sd')['civitai'])
for sd in sdstate[0]: if len(sdstate[0]) > 0 :
if downloadcivitai(sd, 'sd', dlimage): print(f"Missing CivitAI stable-diffusion ids: {sdstate[0]}")
erislocal.get('sd')['civitai'].append(sd) for sd in sdstate[0]:
sdsideloadstate = checksideload(erislocal.get('sd')['sideload'], erisremote.get('sd')['sideload']) if downloadcivitai(sd, 'sd', dlimage):
if len(sdsideloadstate[0]) > 0 : erislocal.get('sd')['civitai'].append(sd)
print(f"Missing Sideload stable-diffusion files: {sdsideloadstate[0]}") sdsideloadstate = checksideload(erislocal.get('sd')['sideload'], erisremote.get('sd')['sideload'])
for sd in sdsideloadstate[0]: if len(sdsideloadstate[0]) > 0 :
if downloadsideload(sd, 'sd'): print(f"Missing Sideload stable-diffusion files: {sdsideloadstate[0]}")
erislocal.get('sd')['sideload'].append(sd) for sd in sdsideloadstate[0]:
if args.cleanup: if downloadsideload(sd, 'sd'):
if len(sdstate[1]) > 0: erislocal.get('sd')['sideload'].append(sd)
print("Additional CivitAI stable-diffusion ids:", sdstate[1]) if args.cleanup:
for delsd in sdstate[1]: if len(sdstate[1]) > 0:
if deleteFiles(delsd, 'lora'): print("Additional CivitAI stable-diffusion ids:", sdstate[1])
erislocal.get('sd')['civitai'].remove(delsd) for delsd in sdstate[1]:
if len(sdsideloadstate[1]) > 0: if deleteFiles(delsd, 'lora'):
print("Additional Sideload stable-diffusion files:", sdstate[1]) erislocal.get('sd')['civitai'].remove(delsd)
for delssd in sdsideloadstate[1]: if len(sdsideloadstate[1]) > 0:
if deleteFiles(delssd, 'lora', True): print("Additional Sideload stable-diffusion files:", sdstate[1])
erislocal.get('sd')['sideload'].remove(delssd) for delssd in sdsideloadstate[1]:
if deleteFiles(delssd, 'lora', True):
if args.skipemb: erislocal.get('sd')['sideload'].remove(delssd)
print("Skip Embedding Model check")
else: if args.skipemb:
embstate = checkcivitai(erislocal.get('emb')['civitai'], erisremote.get('emb')['civitai']) print("Skip Embedding Model check")
if len(embstate[0]) > 0 : else:
print(f"Missing embedding ids: {embstate[0]}") embstate = checkcivitai(erislocal.get('emb')['civitai'], erisremote.get('emb')['civitai'])
for emb in embstate[0]: if len(embstate[0]) > 0 :
if downloadcivitai(emb, 'emb', dlimage): print(f"Missing embedding ids: {embstate[0]}")
erislocal.get('emb')['civitai'].append(emb) for emb in embstate[0]:
embsideloadstate = checksideload(erislocal.get('emb')['sideload'], erisremote.get('emb')['sideload']) if downloadcivitai(emb, 'emb', dlimage):
if len(embsideloadstate[0]) > 0 : erislocal.get('emb')['civitai'].append(emb)
print(f"Missing embedding files: {embsideloadstate[0]}") embsideloadstate = checksideload(erislocal.get('emb')['sideload'], erisremote.get('emb')['sideload'])
for emb in embsideloadstate[0]: if len(embsideloadstate[0]) > 0 :
if downloadsideload(emb, 'emb'): print(f"Missing embedding files: {embsideloadstate[0]}")
erislocal.get('emb')['sideload'].append(emb) for emb in embsideloadstate[0]:
if args.cleanup: if downloadsideload(emb, 'emb'):
if len(embstate[1]) > 0: erislocal.get('emb')['sideload'].append(emb)
print("Additional CivitAI embedding ids:", embstate[1]) if args.cleanup:
for delemb in embstate[1]: if len(embstate[1]) > 0:
if deleteFiles(delemb, 'lora'): print("Additional CivitAI embedding ids:", embstate[1])
erislocal.get('emb')['civitai'].remove(delemb) for delemb in embstate[1]:
if len(embsideloadstate[1]) > 0: if deleteFiles(delemb, 'lora'):
print("Additional Sideload embedding files:", embsideloadstate[1]) erislocal.get('emb')['civitai'].remove(delemb)
for delsemb in embsideloadstate[1]: if len(embsideloadstate[1]) > 0:
if deleteFiles(delsemb, 'lora', True): print("Additional Sideload embedding files:", embsideloadstate[1])
erislocal.get('emb')['sideload'].remove(delsemb) for delsemb in embsideloadstate[1]:
if deleteFiles(delsemb, 'lora', True):
erisjsonfile = open("./eris.json", "w") erislocal.get('emb')['sideload'].remove(delsemb)
erisjsonfile.write(json.dumps(erislocal, indent=2))
erisjsonfile.close() erisjsonfile = open("./eris.json", "w")
erisjsonfile.write(json.dumps(erislocal, indent=2))
erisjsonfile.close()