summaryrefslogtreecommitdiffstats
path: root/releng/management
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-04-29 00:58:13 +0200
committerDan McGee <dan@archlinux.org>2011-04-29 00:58:13 +0200
commitbfe6afcd7ac5ae7b6f07caa7b02a33fec710ebda (patch)
treeec1a4d740d1d594af4646c15118bbf998cd062aa /releng/management
parent11962fab9da3839564fb132109267b8cd6feb6ac (diff)
downloadarchweb-bfe6afcd7ac5ae7b6f07caa7b02a33fec710ebda.tar.gz
archweb-bfe6afcd7ac5ae7b6f07caa7b02a33fec710ebda.tar.xz
Rename isotests to releng
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'releng/management')
-rw-r--r--releng/management/__init__.py0
-rw-r--r--releng/management/commands/__init__.py0
-rw-r--r--releng/management/commands/syncisos.py48
3 files changed, 48 insertions, 0 deletions
diff --git a/releng/management/__init__.py b/releng/management/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/releng/management/__init__.py
diff --git a/releng/management/commands/__init__.py b/releng/management/commands/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/releng/management/commands/__init__.py
diff --git a/releng/management/commands/syncisos.py b/releng/management/commands/syncisos.py
new file mode 100644
index 0000000..247b01c
--- /dev/null
+++ b/releng/management/commands/syncisos.py
@@ -0,0 +1,48 @@
+import re
+import urllib
+from HTMLParser import HTMLParser, HTMLParseError
+
+from django.conf import settings
+from django.core.management.base import BaseCommand, CommandError
+
+from releng.models import Iso
+
+class IsoListParser(HTMLParser):
+ def __init__(self):
+ HTMLParser.__init__(self)
+
+ self.hyperlinks = []
+ self.url_re = re.compile('(?!\.{2})/$')
+
+ def handle_starttag(self, tag, attrs):
+ if tag == 'a':
+ for name, value in attrs:
+ if name == "href":
+ if value != '../' and self.url_re.search(value) != None:
+ self.hyperlinks.append(value[:len(value)-1])
+
+ def parse(self, url):
+ try:
+ remote_file = urllib.urlopen(url)
+ data = remote_file.read()
+ remote_file.close()
+ self.feed(data)
+ self.close()
+ return self.hyperlinks
+ except HTMLParseError:
+ raise CommandError('Couldn\'t parse "%s"' % url)
+
+class Command(BaseCommand):
+ help = 'Gets new isos from %s' % settings.ISO_LIST_URL
+
+ def handle(self, *args, **options):
+ parser = IsoListParser()
+ isonames = Iso.objects.values_list('name', flat=True)
+ new_isos = parser.parse(settings.ISO_LIST_URL)
+
+ for iso in new_isos:
+ if iso not in isonames:
+ new = Iso(name=iso)
+ new.save()
+
+# vim: set ts=4 sw=4 et: