summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2011-04-25 21:53:45 -0400
committerLuke Macken <lmacken@redhat.com>2011-04-25 21:53:45 -0400
commita16a5b45b4e3f70f033900c05d834e345b0aa9f1 (patch)
tree9722c57f7410374b3e66fcc14c59ffe70dcb6eae
parent1eac988c30ab8b0baf02fcc8b4e831f28b1809bd (diff)
Initial code to dynamically fetch fedora releases.
This is not yet integrated into the liveusb-creator itself, but should be in the future.
-rw-r--r--get_releases.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/get_releases.py b/get_releases.py
new file mode 100644
index 0000000..53c222f
--- /dev/null
+++ b/get_releases.py
@@ -0,0 +1,37 @@
+import re
+from urlgrabber import urlread
+
+FEDORA_RELEASES = 'http://download.fedora.redhat.com/pub/fedora/linux/releases/'
+ARCHES = ('i686', 'x86_64')
+
+def get_fedora_releases():
+ releases = []
+ html = urlread(FEDORA_RELEASES)
+ for release in re.findall(r'<a href="(\d+)/">', html)[-2:][::-1]:
+ for arch in ARCHES:
+ arch_url = FEDORA_RELEASES + '%s/Live/%s/' % (release, arch)
+ files = urlread(arch_url)
+ for link in re.findall(r'<a href="(.*)">', files):
+ if link.endswith('-CHECKSUM'):
+ checksum = urlread(arch_url + link)
+ for line in checksum.split('\n'):
+ try:
+ sha256, filename = line.split()
+ if filename[0] != '*':
+ continue
+ filename = filename[1:]
+ chunks = filename[:-4].split('-')
+ chunks.remove('Live')
+ name = ' '.join(chunks)
+ releases.append(dict(
+ name = name,
+ url = arch_url + filename,
+ sha256 = sha256,
+ ))
+ except ValueError:
+ pass
+ return releases
+
+
+from pprint import pprint
+pprint(get_fedora_releases())