Skip to content

Instantly share code, notes, and snippets.

@ownport
Created January 27, 2018 20:29
Show Gist options
  • Save ownport/b60755388538f39a7b9cc171ef6fd0d0 to your computer and use it in GitHub Desktop.
Save ownport/b60755388538f39a7b9cc171ef6fd0d0 to your computer and use it in GitHub Desktop.
Ubuntu release tracker
#!/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