Fix bug in config validator that broke the program
This commit is contained in:
		
							parent
							
								
									647837be27
								
							
						
					
					
						commit
						1bda243430
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		| 
						 | 
					@ -10,7 +10,7 @@ from apscheduler.triggers.cron import CronTrigger
 | 
				
			||||||
# setup logging
 | 
					# setup logging
 | 
				
			||||||
chdir(str(getenv("HOME")) + "/.local/share/wallman/")
 | 
					chdir(str(getenv("HOME")) + "/.local/share/wallman/")
 | 
				
			||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
logging.basicConfig(filename="wallman.log", encoding="utf-8", level=logging.WARNING)
 | 
					logging.basicConfig(filename="wallman.log", encoding="utf-8", level=logging.DEBUG)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# read config
 | 
					# read config
 | 
				
			||||||
        # a = list(data["changing_times"].values())
 | 
					        # a = list(data["changing_times"].values())
 | 
				
			||||||
| 
						 | 
					@ -59,8 +59,10 @@ class ConfigValidity(_ConfigLib):
 | 
				
			||||||
    def _check_fallback_wallpaper(self):
 | 
					    def _check_fallback_wallpaper(self):
 | 
				
			||||||
        if self.config_general["fallback_wallpaper"]:
 | 
					        if self.config_general["fallback_wallpaper"]:
 | 
				
			||||||
            logger.debug("A fallback wallpaper has been defined.")
 | 
					            logger.debug("A fallback wallpaper has been defined.")
 | 
				
			||||||
 | 
					            return True
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            logger.warning("No fallback wallpaper has been provided. If the config is written incorrectly, the program will not be able to be executed.")
 | 
					            logger.warning("No fallback wallpaper has been provided. If the config is written incorrectly, the program will not be able to be executed.")
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _check_wallpapers_per_set_and_changing_times(self) -> bool:
 | 
					    def _check_wallpapers_per_set_and_changing_times(self) -> bool:
 | 
				
			||||||
        # Check if the amount of wallpapers_per_set and given changing times match
 | 
					        # Check if the amount of wallpapers_per_set and given changing times match
 | 
				
			||||||
| 
						 | 
					@ -126,7 +128,7 @@ class ConfigValidity(_ConfigLib):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def validate_config(self) -> None:
 | 
					    def validate_config(self) -> None:
 | 
				
			||||||
        if not self._check_fallback_wallpaper():
 | 
					        if not self._check_fallback_wallpaper():
 | 
				
			||||||
            exit(1)
 | 
					            pass
 | 
				
			||||||
        if not self._check_wallpapers_per_set_and_changing_times():
 | 
					        if not self._check_wallpapers_per_set_and_changing_times():
 | 
				
			||||||
            exit(1)
 | 
					            exit(1)
 | 
				
			||||||
        if not self._check_general_validity():
 | 
					        if not self._check_general_validity():
 | 
				
			||||||
| 
						 | 
					@ -188,6 +190,7 @@ class WallpaperLogic(_ConfigLib):
 | 
				
			||||||
            clean_time_two = self._clean_times(time_range + 1)
 | 
					            clean_time_two = self._clean_times(time_range + 1)
 | 
				
			||||||
            # Check if the current time is between a given and the following changing time and if so, set that wallpaper. If not, keep trying.
 | 
					            # Check if the current time is between a given and the following changing time and if so, set that wallpaper. If not, keep trying.
 | 
				
			||||||
            if self._time_in_range(time(int(clean_time[0]), int(clean_time[1]), int(clean_time[2])), time(int(clean_time_two[0]), int(clean_time_two[1]), int(clean_time_two[2])), datetime.now().time()):
 | 
					            if self._time_in_range(time(int(clean_time[0]), int(clean_time[1]), int(clean_time[2])), time(int(clean_time_two[0]), int(clean_time_two[1]), int(clean_time_two[2])), datetime.now().time()):
 | 
				
			||||||
 | 
					                system(f"feh --bg-scale --no-fehbg --quiet {self.wallpaper_list[time_range]}")
 | 
				
			||||||
                exitcode = system(f"feh --bg-scale --no-fehbg --quiet {self.wallpaper_list[time_range]}")
 | 
					                exitcode = system(f"feh --bg-scale --no-fehbg --quiet {self.wallpaper_list[time_range]}")
 | 
				
			||||||
                has_wallpaper_been_set = self._check_system_exitcode(exitcode)
 | 
					                has_wallpaper_been_set = self._check_system_exitcode(exitcode)
 | 
				
			||||||
                if self.config_notify:
 | 
					                if self.config_notify:
 | 
				
			||||||
| 
						 | 
					@ -196,6 +199,7 @@ class WallpaperLogic(_ConfigLib):
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        system(f"feh --bg-scale --no-fehbg {self.wallpaper_list[-1]}")
 | 
				
			||||||
        exitcode = system(f"feh --bg-scale --no-fehbg {self.wallpaper_list[-1]}")
 | 
					        exitcode = system(f"feh --bg-scale --no-fehbg {self.wallpaper_list[-1]}")
 | 
				
			||||||
        has_wallpaper_been_set = self._check_system_exitcode(exitcode)
 | 
					        has_wallpaper_been_set = self._check_system_exitcode(exitcode)
 | 
				
			||||||
        if self.config_notify:
 | 
					        if self.config_notify:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue