euscanwww: management commands are validators aware
Management commands should create objects that don't raise ValidationError Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
parent
b46e9acc08
commit
fce8ef347b
@ -100,7 +100,10 @@ class ScanMetadata(object):
|
|||||||
name = '{nil}'
|
name = '{nil}'
|
||||||
name = name.strip("\r").strip("\n").strip("\t").strip()
|
name = name.strip("\r").strip("\n").strip("\t").strip()
|
||||||
|
|
||||||
herd, created = Herd.objects.get_or_create(herd=name)
|
herd, created = Herd.objects.get_or_create(
|
||||||
|
herd=name,
|
||||||
|
defaults={"email": email}
|
||||||
|
)
|
||||||
|
|
||||||
if created and not self.quiet:
|
if created and not self.quiet:
|
||||||
sys.stdout.write('+ [h] %s <%s>\n' % (name, email))
|
sys.stdout.write('+ [h] %s <%s>\n' % (name, email))
|
||||||
@ -116,19 +119,16 @@ class ScanMetadata(object):
|
|||||||
if not name:
|
if not name:
|
||||||
name = '{nil}'
|
name = '{nil}'
|
||||||
|
|
||||||
maintainer, created = Maintainer.objects.get_or_create(email=email)
|
maintainer, created = Maintainer.objects.get_or_create(
|
||||||
|
email=email,
|
||||||
|
defaults={"name": name}
|
||||||
|
)
|
||||||
|
|
||||||
if created:
|
if created:
|
||||||
if not self.quiet:
|
if not self.quiet:
|
||||||
sys.stdout.write(
|
sys.stdout.write(
|
||||||
'+ [m] %s <%s>\n' % (name.encode('utf-8'), email)
|
'+ [m] %s <%s>\n' % (name.encode('utf-8'), email)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not maintainer.name or \
|
|
||||||
name not in [maintainer.name, email, '{nil}']:
|
|
||||||
maintainer.name = name
|
|
||||||
maintainer.save()
|
|
||||||
|
|
||||||
return maintainer
|
return maintainer
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,12 +203,13 @@ class ScanPortage(object):
|
|||||||
obj, created = Version.objects.get_or_create(
|
obj, created = Version.objects.get_or_create(
|
||||||
package=package, slot=slot,
|
package=package, slot=slot,
|
||||||
revision=rev, version=ver,
|
revision=rev, version=ver,
|
||||||
overlay=overlay
|
overlay=overlay,
|
||||||
|
defaults={"alive": True, "packaged": True}
|
||||||
)
|
)
|
||||||
|
if not created:
|
||||||
obj.alive = True
|
obj.alive = True
|
||||||
obj.packaged = True
|
obj.packaged = True
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
if created:
|
if created:
|
||||||
self.cache_store_version(obj)
|
self.cache_store_version(obj)
|
||||||
@ -258,15 +259,14 @@ def purge_versions(options):
|
|||||||
if options['no-log']:
|
if options['no-log']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
entry = VersionLog.objects.create(
|
VersionLog.objects.create(
|
||||||
package=version.package,
|
package=version.package,
|
||||||
action=VersionLog.VERSION_REMOVED
|
action=VersionLog.VERSION_REMOVED,
|
||||||
|
slot=version.slot,
|
||||||
|
revision=version.revision,
|
||||||
|
version=version.version,
|
||||||
|
overlay=version.overlay
|
||||||
)
|
)
|
||||||
entry.slot = version.slot
|
|
||||||
entry.revision = version.revision
|
|
||||||
entry.version = version.version
|
|
||||||
entry.overlay = version.overlay
|
|
||||||
entry.save()
|
|
||||||
|
|
||||||
Version.objects.filter(packaged=True, alive=False).delete()
|
Version.objects.filter(packaged=True, alive=False).delete()
|
||||||
|
|
||||||
|
@ -56,13 +56,14 @@ class ScanUpstream(object):
|
|||||||
|
|
||||||
def store_version(self, package, ver, url):
|
def store_version(self, package, ver, url):
|
||||||
obj, created = Version.objects.get_or_create(
|
obj, created = Version.objects.get_or_create(
|
||||||
package=package, slot='', revision='r0', version=ver, overlay=''
|
package=package, slot='', revision='r0', version=ver, overlay='',
|
||||||
|
defaults={"alive": True, "urls": url, "packaged": True}
|
||||||
)
|
)
|
||||||
|
if not created:
|
||||||
obj.alive = True
|
obj.alive = True
|
||||||
obj.urls = url
|
obj.urls = url
|
||||||
obj.packaged = False
|
obj.packaged = False
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
# If it's not a new version, just update the object and continue
|
# If it's not a new version, just update the object and continue
|
||||||
if not created:
|
if not created:
|
||||||
@ -71,15 +72,14 @@ class ScanUpstream(object):
|
|||||||
if not self.options['quiet']:
|
if not self.options['quiet']:
|
||||||
sys.stdout.write('+ [u] %s %s\n' % (obj, url))
|
sys.stdout.write('+ [u] %s %s\n' % (obj, url))
|
||||||
|
|
||||||
entry = VersionLog.objects.create(
|
VersionLog.objects.create(
|
||||||
package=package,
|
package=package,
|
||||||
action=VersionLog.VERSION_ADDED
|
action=VersionLog.VERSION_ADDED,
|
||||||
|
slot='',
|
||||||
|
revision='r0',
|
||||||
|
version=ver,
|
||||||
|
overlay=''
|
||||||
)
|
)
|
||||||
entry.slot = ''
|
|
||||||
entry.revision = 'r0'
|
|
||||||
entry.version = ver
|
|
||||||
entry.overlay = ''
|
|
||||||
entry.save()
|
|
||||||
|
|
||||||
package.n_versions += 1
|
package.n_versions += 1
|
||||||
package.save()
|
package.save()
|
||||||
@ -128,15 +128,14 @@ class ScanUpstream(object):
|
|||||||
def purge_versions(options):
|
def purge_versions(options):
|
||||||
# For each dead versions
|
# For each dead versions
|
||||||
for version in Version.objects.filter(packaged=False, alive=False):
|
for version in Version.objects.filter(packaged=False, alive=False):
|
||||||
entry = VersionLog.objects.create(
|
VersionLog.objects.create(
|
||||||
package=version.package,
|
package=version.package,
|
||||||
action=VersionLog.VERSION_REMOVED
|
action=VersionLog.VERSION_REMOVED,
|
||||||
|
slot=version.slot,
|
||||||
|
revision=version.revision,
|
||||||
|
version=version.version,
|
||||||
|
overlay=version.overlay
|
||||||
)
|
)
|
||||||
entry.slot = version.slot
|
|
||||||
entry.revision = version.revision
|
|
||||||
entry.version = version.version
|
|
||||||
entry.overlay = version.overlay
|
|
||||||
entry.save()
|
|
||||||
|
|
||||||
version.package.n_versions -= 1
|
version.package.n_versions -= 1
|
||||||
version.package.save()
|
version.package.save()
|
||||||
|
Loading…
Reference in New Issue
Block a user