euscanwww: Fixing tasks

Fixing minor bugs in tasks.py and little related stuff

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-06-27 10:15:30 +02:00
parent 1ae2dcba50
commit 951624759a
6 changed files with 18 additions and 19 deletions

View File

@ -272,9 +272,6 @@ class RefreshPackageQuery(models.Model):
query = models.CharField(max_length=256, unique=True)
priority = models.IntegerField(default=0)
class Meta:
get_latest_by = "priority"
def __unicode__(self):
return u'[%d] %s' % (self.priority, self.query)

View File

@ -96,8 +96,8 @@ class ScanMetadata(object):
self.style.ERROR("Bad maintainer: '%s' '%s'" % \
(maintainer.name, maintainer.email))
)
obj.save()
return True
def store_herd(self, name, email):
if not name:
@ -142,6 +142,7 @@ def scan_metadata(packages=None, logger=None):
for pkg in packages:
if isinstance(pkg, Package):
scan_handler.scan('%s/%s' % (pkg.category, pkg.name), pkg)
result = scan_handler.scan('%s/%s' % (pkg.category, pkg.name), pkg)
else:
scan_handler.scan(pkg)
result = scan_handler.scan(pkg)
return result

View File

@ -299,5 +299,5 @@ def scan_portage(packages=None, no_log=False, purge_packages=False,
if purge_versions:
purge_versions(logger=logger, no_log=no_log)
logger.info('Done.')
return True

View File

@ -131,11 +131,12 @@ def scan_upstream(packages=None, purge_versions=False,
for pkg in packages:
if isinstance(pkg, Package):
scan_handler.scan('%s/%s' % (pkg.category, pkg.name))
result = scan_handler.scan('%s/%s' % (pkg.category, pkg.name))
else:
scan_handler.scan(pkg)
result = scan_handler.scan(pkg)
if purge_versions:
purge_versions(logger=logger)
logger.info('Done.')
return result

View File

@ -114,7 +114,7 @@ def scan_metadata_all_task():
@task
def _scan_portage_task(packages, no_logs=False, purge_packages=False,
def _scan_portage_task(packages, no_log=False, purge_packages=False,
purge_versions=False, prefetch=False):
"""
Scans portage for the given set of packages
@ -125,7 +125,7 @@ def _scan_portage_task(packages, no_logs=False, purge_packages=False,
result = scan_portage(
packages=packages,
no_logs=no_logs,
no_log=no_log,
purge_packages=purge_packages,
purge_versions=purge_versions,
prefetch=prefetch,
@ -137,24 +137,24 @@ def _scan_portage_task(packages, no_logs=False, purge_packages=False,
@task
def scan_portage_list_task(query, no_logs=False, purge_packages=False,
def scan_portage_list_task(query, no_log=False, purge_packages=False,
purge_versions=False, prefetch=False):
"""
Runs a parallel portage scan for packages in the query list (space
separated string). Task used only from the web interface.
"""
kwargs = {"no_logs": no_logs, "purge_packages": purge_packages,
kwargs = {"no_log": no_log, "purge_packages": purge_packages,
"purge_versions": purge_versions, "prefetch": prefetch}
_run_in_chunks(_scan_portage_task, [p for p in query.split()], kwargs)
@task
def scan_portage_all_task(no_logs=False, purge_packages=False,
def scan_portage_all_task(no_log=False, purge_packages=False,
purge_versions=False, prefetch=False):
"""
Runs a parallel portage scan for all packages
"""
kwargs = {"no_logs": no_logs, "purge_packages": purge_packages,
kwargs = {"no_log": no_log, "purge_packages": purge_packages,
"purge_versions": purge_versions, "prefetch": prefetch}
_run_in_chunks(_scan_metadata_task, Package.objects.all(), kwargs)
@ -251,8 +251,8 @@ def consume_refresh_package_request():
Satisfies user requests for package refreshing, runs every minute
"""
try:
obj = RefreshPackageQuery.objects.latest()
except RefreshPackageQuery.DoesNotExist:
obj = RefreshPackageQuery.objects.all().order_by('-priority')[0]
except IndexError:
return {}
else:
result = scan_package_task(obj.query)
@ -277,7 +277,7 @@ admin_tasks = [
scan_portage_list_task,
scan_upstream_all_task,
scan_upstream_list_task,
update_portage_trees,
update_portage_trees_task,
update_task,
scan_package_task,
]

View File

@ -73,7 +73,7 @@
});
});
setTimeout(location.reload, 10000);
setTimeout(location.reload, 30000);
});
})(django.jQuery);