def next_photo(self, *_args): """Changes to the next photo.""" reload_config() croot = config.get('collection.dir') if not self.wallpaper_list: self.wallpaper_list = glob.glob( os.path.join(croot, '*', '*.jpg')) png_images = glob.glob( os.path.join(croot, '*', '*.png')) self.wallpaper_list.extend(png_images) random.shuffle(self.wallpaper_list) if self.wallpaper_list: self.last_rotate = time.time()-15 # to ensure next time... wallpaper = self.wallpaper_list.pop() image_file = os.path.join(croot, wallpaper) dirname, base = os.path.split(image_file) basename, _unused_ext = os.path.splitext(base) self.info_file = os.path.join(dirname, basename)+'.inf' self.image_info = infofile.parse_info_file(self.info_file) self.image_file = image_file title = self.image_info.get('title', basename) set_wallpaper(image_file, title) album = self.image_info.get('albumTitle', dirname) self.set_tooltip_for_photo('%s - %s' % (title, album))
def next_photo(self, *_args): """Changes to the next photo.""" reload_config() croot = config.get('collection.dir') if not self.wallpaper_list: self.wallpaper_list = glob.glob(os.path.join(croot, '*', '*.jpg')) png_images = glob.glob(os.path.join(croot, '*', '*.png')) self.wallpaper_list.extend(png_images) random.shuffle(self.wallpaper_list) if self.wallpaper_list: self.last_rotate = time.time() - 15 # to ensure next time... wallpaper = self.wallpaper_list.pop() image_file = os.path.join(croot, wallpaper) set_wallpaper(image_file) dirname, base = os.path.split(image_file) basename, _unused_ext = os.path.splitext(base) info_file = os.path.join(dirname, basename) + '.inf' try: fileobj = open(info_file, 'r') inf = parse_metadata(fileobj.read()) fileobj.close() except IOError: inf = {} self.image_file = image_file self.info_file = info_file title = inf.get('title', basename) album = inf.get('albumTitle', dirname) self.set_tooltip_for_photo('%s - %s' % (title, album))
def timer_event(self, *_args): """Called on regular basis to check if it is time to download photos or change wallpaper.""" try: reload_config() now = time.time() rotate_interval = (config.get('rotate.enabled') and config.get('rotate.interval') * 60) autodownload_interval = (config.get('autodownload.enabled') and config.get('autodownload.interval') * 3600) if rotate_interval: # check if we have to rotate if now - self.last_rotate >= rotate_interval: print "Rotating..." self.next_photo() if CHECK_FOR_UPDATES and now - self.last_version_check >= 8 * 3600: self.last_version_check = now response = VersionCheckerOpener().open(CHECK_URL) latest = response.readlines() response.close() if latest[0].strip() != __version__: self.set_tooltip_announce(''.join(latest[1:])) else: pass if autodownload_interval: if now - self.last_autodownload >= autodownload_interval: print "Time to autodownload." self.last_autodownload = now self.leech_thread = threading.Thread( target=downloader.download_all) self.leech_thread.setDaemon(True) self.leech_thread.start() config.set('autodownload.last_time', now) config.save_config() finally: return True # pylint: disable=W0150
def timer_event(self, *_args): """Called on regular basis to check if it is time to download photos or change wallpaper.""" try: reload_config() now = time.time() rotate_interval = (config.get('rotate.enabled') and config.get('rotate.interval')*60) autodownload_interval = (config.get('autodownload.enabled') and config.get('autodownload.interval')*3600) if rotate_interval: # check if we have to rotate if now-self.last_rotate >= rotate_interval: print "Rotating..." self.next_photo() if CHECK_FOR_UPDATES and now-self.last_version_check >= 8*3600: self.last_version_check = now response = VersionCheckerOpener().open(CHECK_URL) latest = response.readlines() response.close() if latest[0].strip() != __version__: self.set_tooltip_announce(''.join(latest[1:])) else: pass if autodownload_interval: if now-self.last_autodownload >= autodownload_interval: print "Time to autodownload." self.last_autodownload = now self.leech_thread = threading.Thread( target=downloader.download_all) self.leech_thread.setDaemon(True) self.leech_thread.start() config.set('autodownload.last_time', now) config.save_config() finally: return True # pylint: disable=W0150
def current(self, _action): """Opens the current dialog.""" reload_config() CurrentDialog.show_current_dialog(config.get('wallpaper.title'), config.get('wallpaper.path'))
def configure(): """Shows the configuration dialog.""" reload_config() config_dialog.ConfigDialog().run_dialog(config)