mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
remove error thrown when no suitable library found
This commit is contained in:
parent
f6f6bfad70
commit
270abc5167
@ -97,22 +97,20 @@ class D3DShot(IScreenShot):
|
||||
LIBS = [PyAutoGUI, MSS, D3DShot]
|
||||
|
||||
def create() -> IScreenShot:
|
||||
# Attempt to use D3DShot if performance is critical and it's specified in the config
|
||||
preferred_lib = config.get("sslib", None)
|
||||
if preferred_lib == "d3dshot":
|
||||
logging.debug("Attempting to use D3DShot (fast) as the screenshot library...")
|
||||
d3dshot_instance = D3DShot()
|
||||
if d3dshot_instance.setup():
|
||||
return d3dshot_instance
|
||||
else:
|
||||
logging.warning("D3DShot setup failed. Falling back to default method...")
|
||||
|
||||
# Default to PyAutoGUI if D3DShot is not explicitly chosen or fails to set up
|
||||
for lib in LIBS:
|
||||
lib_instance = lib()
|
||||
if lib_instance.setup():
|
||||
logging.debug(f"Using {lib.__name__} as the screenshot library.")
|
||||
return lib_instance
|
||||
|
||||
# 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
|
||||
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.")
|
||||
raise Exception("Failed to initialize a screenshot library.")
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user