def main(daemon=None): if daemon: _logger.info('daemon %s triggers an update', str(daemon)) # reload config again in case the config file has been modified after #last shooting configdb = prepare_config_db() run_config = load_config(configdb) setter.load_ext_setters(dirname(abspath(argv[0]))) prepare_output_dir(run_config.output_folder) load_history() install_proxy(run_config) filerecord = download_wallpaper(run_config) if filerecord: save_history(filerecord) if not filerecord or run_config.setter == 'no': _logger.info('nothing to set') else: s = setter.get(run_config.setter)() _logger.info('setting wallpaper %s', filerecord['local_file']) s.set(filerecord['local_file'], run_config.setter_args) _logger.info('all done. enjoy your new wallpaper') if daemon: schedule_next_poll(run_config, daemon)
def main(daemon=None): if daemon: _logger.info('daemon %s triggers an update', str(daemon)) # reload config again in case the config file has been modified after #last shooting configdb = prepare_config_db() run_config = load_config(configdb) setter.load_ext_setters(dirname(abspath(argv[0]))) prepare_output_dir(run_config.output_folder) prepare_output_dir(dirname(HISTORY_FILE)) load_history() install_proxy(run_config) try: filerecords = download_wallpaper(run_config) except CannotLoadImagePage: if not run_config.foreground and run_config.background and daemon: _logger.info( "network error happened, daemon will retry in 60 seconds") timeout = 60 else: _logger.info( "network error happened. please retry after Internet connection restore." ) filerecords = None else: timeout = run_config.interval * 3600 if filerecords: save_history(filerecords) if not filerecords or run_config.setter == 'no': _logger.info('nothing to set') else: s = setter.get(run_config.setter)() # use the first image as wallpaper, accompanying images are just # to fulfill your collection wallpaper_record = filerecords[0] _logger.info('setting wallpaper %s', wallpaper_record['local_file']) s.set(wallpaper_record['local_file'], run_config.setter_args) _logger.info('all done. enjoy your new wallpaper') if not run_config.foreground and run_config.background and daemon: schedule_next_poll(timeout, daemon) elif run_config.foreground: _logger.info('force foreground mode from command line')
def main(daemon=None): if daemon: _logger.info('daemon %s triggers an update', str(daemon)) # reload config again in case the config file has been modified after #last shooting configdb = prepare_config_db() run_config = load_config(configdb) setter.load_ext_setters(dirname(abspath(argv[0]))) prepare_output_dir(run_config.output_folder) prepare_output_dir(dirname(HISTORY_FILE)) load_history() install_proxy(run_config) try: filerecords = download_wallpaper(run_config) except CannotLoadImagePage: if not run_config.foreground and run_config.background and daemon: _logger.info("network error happened, daemon will retry in 60 seconds") timeout = 60 else: _logger.info("network error happened. please retry after Internet connection restore.") filerecords = None else: timeout = run_config.interval*3600 if filerecords: save_history(filerecords) if not filerecords or run_config.setter == 'no': _logger.info('nothing to set') else: s = setter.get(run_config.setter)() # use the first image as wallpaper, accompanying images are just # to fulfill your collection wallpaper_record = filerecords[0] _logger.info('setting wallpaper %s', wallpaper_record['local_file']) s.set(wallpaper_record['local_file'], run_config.setter_args) _logger.info('all done. enjoy your new wallpaper') if not run_config.foreground and run_config.background and daemon: schedule_next_poll(timeout, daemon) elif run_config.foreground: _logger.info('force foreground mode from command line')
def main(config, daemon=None): if daemon: _logger.info('daemon %s triggers an update', str(daemon)) setter.load_ext_setters(dirname(abspath(argv[0]))) prepare_output_dir(config.output_folder) load_history() filerecord = download_wallpaper(config) if filerecord: save_history(filerecord) if not filerecord or config.setter == 'no': _logger.info('nothing to set') else: s = setter.get(config.setter)() _logger.info('setting wallpaper %s', filerecord['local_file']) s.set(filerecord['local_file'], config.setter_args) _logger.info('all done. enjoy your new wallpaper') if daemon: schedule_next_poll(config, daemon)
l = log.PAGEDUMP _logger.setLevel(l) webutil._logger.setLevel(l) log._logger.setLevel(l) ngphoto._logger.setLevel(l) setter.loglevel = l if __name__ == '__main__': config = parseargs(argv[1:]) set_debug_details(config.debug) _logger.debug(config) setter.load_ext_setters(dirname(abspath(argv[0]))) prepare_output_dir(config.output_folder) load_history() filerecord = download_wallpaper(config) if filerecord: save_history(filerecord) if not filerecord or config.setter == 'no': _logger.info('nothing to set') else: s = setter.get(config.setter)() _logger.info('setting wallpaper %s', filerecord['local_file']) s.set(filerecord['local_file'], config.setter_args) sysexit(0)