def check_version(force=False): cache = Cache(filename="cli.json") latest_version = cache.get("latest_version") if force or not latest_version: res = requests.get("https://pypi.python.org/pypi/livestreamer/json") data = res.json() latest_version = data.get("info").get("version") cache.set("latest_version", latest_version, (60 * 60 * 24)) version_info_printed = cache.get("version_info_printed") if not force and version_info_printed: return installed_version = StrictVersion(livestreamer.version) latest_version = StrictVersion(latest_version) if latest_version > installed_version: console.logger.info("A new version of Livestreamer ({0}) is " "available!".format(latest_version)) cache.set("version_info_printed", True, (60 * 60 * 6)) elif force: console.logger.info("Your Livestreamer version ({0}) is up to date!", installed_version) if force: sys.exit()
def check_version(): cache = Cache(filename="cli.json") latest_version = cache.get("latest_version") if not latest_version: res = requests.get("https://pypi.python.org/pypi/livestreamer/json") data = res.json() latest_version = data.get("info").get("version") cache.set("latest_version", latest_version, (60 * 60 * 24)) installed_version = StrictVersion(livestreamer.version) latest_version = StrictVersion(latest_version) if latest_version > installed_version: console.logger.info("A new version of Livestreamer ({0}) is " "available!".format(latest_version))