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:
parent
1ae2dcba50
commit
951624759a
@ -272,9 +272,6 @@ class RefreshPackageQuery(models.Model):
|
|||||||
query = models.CharField(max_length=256, unique=True)
|
query = models.CharField(max_length=256, unique=True)
|
||||||
priority = models.IntegerField(default=0)
|
priority = models.IntegerField(default=0)
|
||||||
|
|
||||||
class Meta:
|
|
||||||
get_latest_by = "priority"
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u'[%d] %s' % (self.priority, self.query)
|
return u'[%d] %s' % (self.priority, self.query)
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ class ScanMetadata(object):
|
|||||||
self.style.ERROR("Bad maintainer: '%s' '%s'" % \
|
self.style.ERROR("Bad maintainer: '%s' '%s'" % \
|
||||||
(maintainer.name, maintainer.email))
|
(maintainer.name, maintainer.email))
|
||||||
)
|
)
|
||||||
|
|
||||||
obj.save()
|
obj.save()
|
||||||
|
return True
|
||||||
|
|
||||||
def store_herd(self, name, email):
|
def store_herd(self, name, email):
|
||||||
if not name:
|
if not name:
|
||||||
@ -142,6 +142,7 @@ def scan_metadata(packages=None, logger=None):
|
|||||||
|
|
||||||
for pkg in packages:
|
for pkg in packages:
|
||||||
if isinstance(pkg, Package):
|
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:
|
else:
|
||||||
scan_handler.scan(pkg)
|
result = scan_handler.scan(pkg)
|
||||||
|
return result
|
||||||
|
@ -299,5 +299,5 @@ def scan_portage(packages=None, no_log=False, purge_packages=False,
|
|||||||
|
|
||||||
if purge_versions:
|
if purge_versions:
|
||||||
purge_versions(logger=logger, no_log=no_log)
|
purge_versions(logger=logger, no_log=no_log)
|
||||||
|
|
||||||
logger.info('Done.')
|
logger.info('Done.')
|
||||||
|
return True
|
||||||
|
@ -131,11 +131,12 @@ def scan_upstream(packages=None, purge_versions=False,
|
|||||||
|
|
||||||
for pkg in packages:
|
for pkg in packages:
|
||||||
if isinstance(pkg, Package):
|
if isinstance(pkg, Package):
|
||||||
scan_handler.scan('%s/%s' % (pkg.category, pkg.name))
|
result = scan_handler.scan('%s/%s' % (pkg.category, pkg.name))
|
||||||
else:
|
else:
|
||||||
scan_handler.scan(pkg)
|
result = scan_handler.scan(pkg)
|
||||||
|
|
||||||
if purge_versions:
|
if purge_versions:
|
||||||
purge_versions(logger=logger)
|
purge_versions(logger=logger)
|
||||||
|
|
||||||
logger.info('Done.')
|
logger.info('Done.')
|
||||||
|
return result
|
||||||
|
@ -114,7 +114,7 @@ def scan_metadata_all_task():
|
|||||||
|
|
||||||
|
|
||||||
@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):
|
purge_versions=False, prefetch=False):
|
||||||
"""
|
"""
|
||||||
Scans portage for the given set of packages
|
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(
|
result = scan_portage(
|
||||||
packages=packages,
|
packages=packages,
|
||||||
no_logs=no_logs,
|
no_log=no_log,
|
||||||
purge_packages=purge_packages,
|
purge_packages=purge_packages,
|
||||||
purge_versions=purge_versions,
|
purge_versions=purge_versions,
|
||||||
prefetch=prefetch,
|
prefetch=prefetch,
|
||||||
@ -137,24 +137,24 @@ def _scan_portage_task(packages, no_logs=False, purge_packages=False,
|
|||||||
|
|
||||||
|
|
||||||
@task
|
@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):
|
purge_versions=False, prefetch=False):
|
||||||
"""
|
"""
|
||||||
Runs a parallel portage scan for packages in the query list (space
|
Runs a parallel portage scan for packages in the query list (space
|
||||||
separated string). Task used only from the web interface.
|
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}
|
"purge_versions": purge_versions, "prefetch": prefetch}
|
||||||
_run_in_chunks(_scan_portage_task, [p for p in query.split()], kwargs)
|
_run_in_chunks(_scan_portage_task, [p for p in query.split()], kwargs)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@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):
|
purge_versions=False, prefetch=False):
|
||||||
"""
|
"""
|
||||||
Runs a parallel portage scan for all packages
|
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}
|
"purge_versions": purge_versions, "prefetch": prefetch}
|
||||||
_run_in_chunks(_scan_metadata_task, Package.objects.all(), kwargs)
|
_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
|
Satisfies user requests for package refreshing, runs every minute
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
obj = RefreshPackageQuery.objects.latest()
|
obj = RefreshPackageQuery.objects.all().order_by('-priority')[0]
|
||||||
except RefreshPackageQuery.DoesNotExist:
|
except IndexError:
|
||||||
return {}
|
return {}
|
||||||
else:
|
else:
|
||||||
result = scan_package_task(obj.query)
|
result = scan_package_task(obj.query)
|
||||||
@ -277,7 +277,7 @@ admin_tasks = [
|
|||||||
scan_portage_list_task,
|
scan_portage_list_task,
|
||||||
scan_upstream_all_task,
|
scan_upstream_all_task,
|
||||||
scan_upstream_list_task,
|
scan_upstream_list_task,
|
||||||
update_portage_trees,
|
update_portage_trees_task,
|
||||||
update_task,
|
update_task,
|
||||||
scan_package_task,
|
scan_package_task,
|
||||||
]
|
]
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(location.reload, 10000);
|
setTimeout(location.reload, 30000);
|
||||||
|
|
||||||
});
|
});
|
||||||
})(django.jQuery);
|
})(django.jQuery);
|
||||||
|
Loading…
Reference in New Issue
Block a user