Skip `Unable to load tagging script` if not windows. Fix reading seed value if None. Possible fix for `Unable to write tag or category for`

main
Trung Ngo 2022-11-04 00:38:37 -05:00
parent e6e31804e4
commit 3c362845f5
2 changed files with 6 additions and 4 deletions

View File

@ -172,7 +172,7 @@ class AISGroups:
if choice in choices_selected:
choice_values.update({choice: processor(params)})
if "seed" in choice_values and int(choice_values["seed"]) == -1:
if "seed" in choice_values and choice_values["seed"] is not None and int(choice_values["seed"]) == -1:
choice_values["seed"] = int(parsed_info["Seed"]) if "Seed" in parsed_info else int(choice_values["seed"])
for group in self.groups:
@ -251,7 +251,7 @@ def on_image_saved(params: ImageSaveParams):
if tag_files is not None:
tag_files(filename=filename, tags=applied["tags"], categories=applied["categories"],
log_prefix=f"{extension_name}: ")
else:
elif platform.system() == "Windows":
print(f"{extension_name}: Unable to load tagging script")
class AestheticImageScorer(scripts.Script):

View File

@ -1,3 +1,4 @@
import platform
import sys
# requires pywin32 (See requirements.txt. Supports Windows only obviously)
# also recommend FileMeta https://github.com/Dijji/FileMeta to allow tags for PNG
@ -51,7 +52,7 @@ def set_property(file="", property="System.Keywords", values=[], remove_values=[
return ps
def tag_files(files_glob="", tags=[], remove_tags=[], remove_all_tags=False, filename="", comment="", categories=[], remove_categories=[], remove_all_categories=False, log_prefix=""):
if propsys == None or shellcon == None:
if propsys == None or shellcon == None or platform.system() != "Windows":
return
if files_glob=="":
@ -65,7 +66,8 @@ def tag_files(files_glob="", tags=[], remove_tags=[], remove_all_tags=False, fil
remove_values=remove_tags, remove_all=remove_all_tags)
ps = set_property(file=file, property="System.Category", values=categories,
remove_values=remove_categories, remove_all=remove_all_categories, ps=ps)
ps.Commit()
if ps is not None:
ps.Commit()
except:
print(f"{log_prefix}Unable to write tag or category for {file}")