euscanwww: Added tasks for syncing and updating portage tree

Added these tasks:
 * emerge_sync
 * layman_sync
 * emerge_regen
 * eix_update

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-06-04 11:06:47 +02:00
parent 2edb220d3e
commit 60e2019cc3
3 changed files with 56 additions and 6 deletions

View File

@ -1,8 +1,12 @@
import subprocess
from StringIO import StringIO
from celery.task import task
from celery.task.sets import TaskSet
from djeuscan.models import Package
from django.conf import settings
from djeuscan.models import Package
from djeuscan.management.commands.regen_rrds import regen_rrds
from djeuscan.management.commands.update_counters import update_counters
from djeuscan.management.commands.scan_metadata import ScanMetadata
@ -97,6 +101,41 @@ def scan_upstream_purge_task():
scan_upstream_purge()
def _launch_command(cmd):
fp = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output = StringIO(fp.communicate()[0])
return output.getvalue()
@task
def emerge_sync():
cmd = ["emerge", "--sync", "--root", settings.PORTAGE_ROOT,
"--config-root", settings.PORTAGE_CONFIGROOT]
return _launch_command(cmd)
@task
def layman_sync():
cmd = ["layman", "-S", "--config", settings.LAYMAN_CONFIG]
return _launch_command(cmd)
@task
def emerge_regen():
cmd = [
"emerge", "--regen", "--jobs", settings.EMERGE_REGEN_JOBS, "--root",
settings.PORTAGE_ROOT, "--config-root", settings.PORTAGE_CONFIGROOT
]
return _launch_command(cmd)
@task
def eix_update():
cmd = ["eix-update"]
return _launch_command(cmd)
launchable_tasks = [
regen_rrds_task,
update_counters_task,
@ -108,4 +147,8 @@ launchable_tasks = [
scan_upstream_all_task,
scan_upstream_task,
scan_upstream_purge_task,
emerge_sync,
layman_sync,
emerge_regen,
eix_update,
]

View File

@ -202,6 +202,12 @@ LOGGING = {
}
PORTAGE_ROOT = "/usr/portage/"
PORTAGE_CONFIGROOT = PORTAGE_ROOT
LAYMAN_CONFIG = "/etc/layman/layman.cfg"
EMERGE_REGEN_JOBS = 4
# Celery config
import djcelery
djcelery.setup_loader()
@ -213,7 +219,7 @@ try:
from local_settings import *
except ImportError, ex:
import sys
sys.stderr.write(\
("settings.py: error importing local settings file:\n" + \
"\t%s\n" + \
"Do you have a local_settings.py module?\n") % str(ex))
sys.stderr.write(
"settings.py: error importing local settings file:\n"
"\t%s\nDo you have a local_settings.py module?\n" % str(ex)
)

View File

@ -1,6 +1,7 @@
#!/usr/bin/python
import sys, os
import sys
import os
import os.path
PROJECT = '/path/to/euscanwww'