summaryrefslogtreecommitdiff
path: root/isotests/management/commands/syncisos.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-04-28 13:59:53 -0500
committerDan McGee <dan@archlinux.org>2011-04-28 14:00:54 -0500
commit6516220b17d7987900961863a0b6dec23ac14855 (patch)
tree8988d3233e32c6038f6c069d742e2896673a6b98 /isotests/management/commands/syncisos.py
parent1ea5be1a0693d8f24b5d147092fd4a15c7fdd4a7 (diff)
isotests: update some syntax and ways of doing things
To be more Django-like, Pythonic, or to fit better in the existing archweb project. Also add some created fields to the models, as storing dates for anything is almost always a good idea. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'isotests/management/commands/syncisos.py')
-rw-r--r--isotests/management/commands/syncisos.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/isotests/management/commands/syncisos.py b/isotests/management/commands/syncisos.py
index 4cc6908e..9c76ccda 100644
--- a/isotests/management/commands/syncisos.py
+++ b/isotests/management/commands/syncisos.py
@@ -2,10 +2,10 @@ import re
import urllib
from HTMLParser import HTMLParser, HTMLParseError
+from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from isotests.models import Iso
-from settings import ISOLISTURL
class IsoListParser(HTMLParser):
def __init__(self):
@@ -23,25 +23,22 @@ class IsoListParser(HTMLParser):
def parse(self, url):
try:
- f = urllib.urlopen(url)
-
- s = f.read()
- f.close()
-
- self.feed(s)
+ 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' % ISOLISTURL
+ 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(ISOLISTURL)
+ new_isos = parser.parse(settings.ISO_LIST_URL)
for iso in new_isos:
if iso not in isonames: