Ejemplo n.º 1
0
 def start_prev_profile(self, profile):
     """Checks if a previously running profile has been recorded and starts it."""
     with self.job_lock:
         if profile is None:
             sp_logging.G_LOGGER.info("No previous profile was found.")
         else:
             self.repeating_timer = run_profile_job(profile)
Ejemplo n.º 2
0
    def start_profile(self, event, profile):
        """
        Starts a profile job, i.e. runs a slideshow or a one time wallpaper change.

        If the input profile is the currently active profile, initiate a wallpaper change.
        """
        if sp_logging.DEBUG:
            sp_logging.G_LOGGER.info("Start profile: %s", profile.name)
        if profile is None:
            sp_logging.G_LOGGER.info("start_profile: profile is None. \
                Do you have any profiles in /profiles?")
        elif self.active_profile is not None:
            if sp_logging.DEBUG:
                sp_logging.G_LOGGER.info(
                    "Check if the starting profile is already running: %s",
                    profile.name)
                sp_logging.G_LOGGER.info("name check: %s, %s", profile.name,
                                         self.active_profile.name)
            if profile.name == self.active_profile.name:
                self.next_wallpaper(event)
                return 0
            else:
                with self.job_lock:
                    if (self.repeating_timer is not None
                            and self.repeating_timer.is_running):
                        self.repeating_timer.stop()
                    if sp_logging.DEBUG:
                        sp_logging.G_LOGGER.info(
                            "Running quick profile job with profile: %s",
                            profile.name)
                    quick_profile_job(profile)
                    if sp_logging.DEBUG:
                        sp_logging.G_LOGGER.info(
                            "Starting timed profile job with profile: %s",
                            profile.name)
                    self.repeating_timer = run_profile_job(profile)
                    self.active_profile = profile
                    write_active_profile(profile.name)
                    if sp_logging.DEBUG:
                        sp_logging.G_LOGGER.info("Wrote active profile: %s",
                                                 profile.name)
                    return 0
        else:
            with self.job_lock:
                if (self.repeating_timer is not None
                        and self.repeating_timer.is_running):
                    self.repeating_timer.stop()
                if sp_logging.DEBUG:
                    sp_logging.G_LOGGER.info(
                        "Running quick profile job with profile: %s",
                        profile.name)
                quick_profile_job(profile)
                if sp_logging.DEBUG:
                    sp_logging.G_LOGGER.info(
                        "Starting timed profile job with profile: %s",
                        profile.name)
                self.repeating_timer = run_profile_job(profile)
                self.active_profile = profile
                write_active_profile(profile.name)
                if sp_logging.DEBUG:
                    sp_logging.G_LOGGER.info("Wrote active profile: %s",
                                             profile.name)
                return 0