File transfer

This commit is contained in:
Emma Nora Ada Theuer 2025-03-07 17:30:26 +01:00
parent bcd33f4802
commit b2268f31bd

View file

@ -25,6 +25,11 @@ class _Config:
print("CRITICAL: The general dictionary was not found or contains errors")
raise ConfigError("The general dictionary was not found or contains errors")
# Changing times
self.use_fallback_wallpaper: bool = self._validate_fallback_wallpaper():
if not self.use_fallback_wallpaper:
logger.warning("No fallback wallpaper will be used.")
else:
logger.debug(f"Using Fallback wallpaper: {self.config_fallback_wallpaper}")
valid_changing_times: bool = self._initialize_changing_times()
if not valid_changing_times:
logger.critical(
@ -129,19 +134,12 @@ class _Config:
return behavior
def _set_fallback_wallpaper(self) -> None:
if self.config_fallback_wallpaper:
successfully_set: int = system(
f"feh {self.config_behavior} --no-fehbg {self.config_fallback_wallpaper}"
)
if successfully_set == 0:
logger.info("The fallback Wallpaper has been set.")
else:
logger.critical(
"An Error occured and no fallback wallpaper was provided, exiting..."
)
raise ConfigError(
"An error occured and no fallback wallpaper has been set, exiting..."
)
if self.use_fallback_wallpaper:
system(f"feh {self.config_behavior} --no-fehbg {self.config_fallback_wallpaper}")
logger.info("The fallback Wallpaper has been set.")
else:
logger.critical("An Error occured and not being used. Exiting...")
raise ConfigError("An Error occured and not being used.")
def _initialize_general(self) -> bool:
# Create Config General Dict
@ -298,13 +296,71 @@ class _Config:
return False
except ConfigError:
logger.critical(
f"Dictionary {wallpaper_set} does not have sufficient entries, exciting..."
f"Dictionary {wallpaper_set} does not have sufficient entries, exiting..."
)
print(
f"Dictionary {wallpaper_set} does not have sufficient entries, exciting..."
f"Dictionary {wallpaper_set} does not have sufficient entries, exiting..."
)
return False
def _validate_fallback_wallpaper(self) -> bool:
if not isinstance(self.config_fallback_wallpaper, str):
logger.error("The type of fallback_wallpaper in the config file is incorrect. Should be string.")
print("ERROR: The type of fallback_wallpaper in the config file is incorrect. Should be string.")
return False
if not path.isfile(self.config_fallback_wallpaper):
logger.error("No fallback wallpaper with the specified name could be found.")
print("ERROR: No fallback wallpaper with the specified name could be found.")
return False
logger.debug("The Type of the fallback wallpaper is correct and it exists.")
return True
def _validate_types(self) -> bool:
# Loglevel
if not isinstance(self.config_log_level, str) and not isinstance(self._set_log_level, int):
logger.critical("Expected type of loglevel to be int or str. Got incorrect type. Exiting...")
print("CRITICAL: Expected type of loglevel to be int or str. Got incorrect type. Exiting...")
self._set_fallback_wallpaper()
return False
else:
logger.debug("The type for loglevel in the config has a valid type.")
# Wallpapers per set
if not isinstance(self.config_wallpapers_per_set, int):
logger.critical("The type of wallpaper_per_set in the config is incorrect. Expected int.")
print("CRITICAL: The type of wallpaper_per_set in the config is incorrect. Expected int.")
return False
else:
logger.debug("The type of wallpapers_per_set is correct.")
# enable_wallpaper_sets
if not isinstance(self.config_wallpaper_sets_enabled, bool):
logger.critical("The type of enable_wallpaper_sets is incorrect. Expected bool.")
print("CRITICAL: The type of enable_wallpaper_sets is incorrect. Expected bool.")
else:
logger.debug("The type of enable_wallpaper_sets is bool.")
# used_sets
if not isinstance(self.config_used_sets, list):
logger.critical("The type of used_sets in the config is not an array, exiting.")
print("CRITICAL: The type of used_sets in the config is not an array, exiting.")
else:
logger.debug("used_sets is an array")
for i in range(self.config_wallpapers_per_set):
if not isinstance(self.config_used_sets[i], str):
print(f"CRITICAL: The type of index {i} in used_sets in the config is not str. Exiting...")
logger.critical(f"The type of index {i} in used_sets in the config is not str. Exiting...")
return False
else:
logger.debug(f"The type of index {i} of used_sets in the config is correct.")
logger.debug("used_sets is a list of strings.")
# systray
if not isinstance(self.config_systray, bool):
logger.error("")
return True
# TODO: Improve modularity. See notes inside the class for more details.
# TODO: Ensure functionality and if needed add handling for the 1 wallpaper per set case.