Created
January 27, 2018 20:29
-
-
Save ownport/b60755388538f39a7b9cc171ef6fd0d0 to your computer and use it in GitHub Desktop.
Ubuntu release tracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import re | |
import sys | |
import time | |
import requests | |
URL = "http://releases.ubuntu.com/16.04/" | |
def t(): | |
return time.strftime('%Y-%m-%d %H:%M:%S',time.gmtime()) | |
if len(sys.argv) > 1: | |
time_interval = int(sys.argv[1]) | |
else: | |
print >> sys.stderr, "usage: ./ubuntu-release-tracker.py <time interval>" | |
sys.exit(1) | |
print "%s Checking %s" % (t(), URL) | |
try: | |
while True: | |
version = ''.join(re.findall(r'<h1>(.*)</h1>', requests.get(URL, timeout=60).content)) | |
print t(), version | |
if time_interval == 0: | |
break | |
time.sleep(time_interval) | |
except KeyboardInterrupt: | |
print "Interrupted by user" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment