diff options
author | Parabola <dev@list.parabolagnulinux.org> | 2011-12-05 01:29:30 +0000 |
---|---|---|
committer | Parabola <dev@list.parabolagnulinux.org> | 2011-12-05 01:29:30 +0000 |
commit | 420a9ea6ab7a912f2288b6f8e852ea2e19556ec9 (patch) | |
tree | b337b7e29cf8303d0b78b5cb165919ffc1a57c4a /releng/management/commands/syncisos.py | |
parent | 9426870d705cdc8f18b860e00da909e0e812bef7 (diff) | |
parent | 183c4d9cefa95f46c3fa3a6936f837542426eac2 (diff) |
Merge branch 'master' of /srv/git/repositories/parabolaweb
Diffstat (limited to 'releng/management/commands/syncisos.py')
-rw-r--r-- | releng/management/commands/syncisos.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/releng/management/commands/syncisos.py b/releng/management/commands/syncisos.py index ba174131..270c6c34 100644 --- a/releng/management/commands/syncisos.py +++ b/releng/management/commands/syncisos.py @@ -1,3 +1,4 @@ +from datetime import datetime import re import urllib from HTMLParser import HTMLParser, HTMLParseError @@ -33,19 +34,28 @@ class IsoListParser(HTMLParser): raise CommandError('Couldn\'t parse "%s"' % url) class Command(BaseCommand): - help = 'Gets new isos from %s' % settings.ISO_LIST_URL + 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) active_isos = parser.parse(settings.ISO_LIST_URL) - # create any names that don't already exist for iso in active_isos: + # create any names that don't already exist if iso not in isonames: new = Iso(name=iso, active=True) new.save() + # update those that do if they were marked inactive + else: + existing = Iso.objects.get(name=iso) + if not existing.active: + existing.active = True + existing.removed = None + existing.save() + now = datetime.utcnow() # and then mark all other names as no longer active - Iso.objects.exclude(name__in=active_isos).update(active=False) + Iso.objects.filter(active=True).exclude(name__in=active_isos).update( + active=False, removed=now) # vim: set ts=4 sw=4 et: |