hotfix 0.5.24 testing grab once before providing the ss lib

This commit is contained in:
Adam Saudagar 2024-03-13 15:11:34 +05:30
parent 106eca4980
commit 0efa8138da
2 changed files with 8 additions and 5 deletions

View File

@ -96,21 +96,24 @@ class D3DShot(IScreenShot):
LIBS = [PyAutoGUI, MSS, D3DShot]
def create() -> IScreenShot:
def create() -> Optional[IScreenShot]:
# Initialize a variable to hold the preferred library index
preferred_lib_index = config.get("sslib", 0)
# Create a list of library indices to try, starting with the preferred one
lib_indices = [preferred_lib_index] + [i for i in range(len(LIBS)) if i != preferred_lib_index]
for index in lib_indices:
lib = LIBS[index]
try:
lib_instance = lib()
if lib_instance.setup():
logging.debug(f"Using {lib.__name__} as the screenshot library.")
return lib_instance
# testing grab once
ss = lib_instance.grab()
if ss:
return lib_instance
except Exception as e:
logging.warning(f"Setup failed for {lib.__name__} with error: {str(e)}. Trying next library...")
logging.error("No suitable screenshot library found. Please check your configuration.")
return None

View File

@ -1 +1 @@
0.5.23
0.5.24