aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-07-03 13:29:11 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-07-03 13:29:11 +0530
commit5cdbaa009facb2dec15d0a3e89751022759c17dc (patch)
treeacc7e6bd5748bffacae8938ab7ee12387bd8637d
parentNo matter how hard I try, I can't seem to be able to make atomic commits :( (diff)
downloadautotua-5cdbaa009facb2dec15d0a3e89751022759c17dc.tar.gz
autotua-5cdbaa009facb2dec15d0a3e89751022759c17dc.tar.bz2
autotua-5cdbaa009facb2dec15d0a3e89751022759c17dc.zip
- Implement a jobuild processor: autotua.jobuild.Processor()
- Insert placeholder for running phases inside a chroot (autotua/bin/jobuild.sh) - Remove a stray debug print
-rwxr-xr-xslave/autotua/bin/jobuild.sh10
-rw-r--r--slave/autotua/jobuild/__init__.py41
2 files changed, 45 insertions, 6 deletions
diff --git a/slave/autotua/bin/jobuild.sh b/slave/autotua/bin/jobuild.sh
index 668d019..bfd57ec 100755
--- a/slave/autotua/bin/jobuild.sh
+++ b/slave/autotua/bin/jobuild.sh
@@ -33,10 +33,18 @@ get_var() {
speak $(get_param "${1}" "${2}")
}
+run_phase() {
+ echo "Placeholder phase \"runner\""
+ echo "Running phase \"${1}\" from \"${2}\" inside \"${3}\""
+}
+
case "${1}" in
- GET)
+ GET_VAR)
get_var "${2}" "${3}"
;;
+ RUN_PHASE)
+ run_phase "${2}" "${3}" "${4}" # phase jobuild chroot
+ ;;
*)
speak "error: no such action"
;;
diff --git a/slave/autotua/jobuild/__init__.py b/slave/autotua/jobuild/__init__.py
index 14ebad4..98d6a8e 100644
--- a/slave/autotua/jobuild/__init__.py
+++ b/slave/autotua/jobuild/__init__.py
@@ -17,9 +17,16 @@ class Jobuild(object):
"""A jobuild"""
def __init__(self, jobdir, atom):
+ """
+ @param jobdir: Job directory (of the form tmpdir/maint/job_name)
+ @type jobdir: string
+
+ @param atom: Atom for finding the corresponding jobuild
+ @type jobdir: string
+ """
self.name = atom
self.jobdir = jobdir
- self.jobuild = self._best_jobuild(atom)
+ self.path = self._best_jobuild(atom)
def __str__(self):
return '%s jobuild object' % self.name
@@ -50,7 +57,6 @@ class Jobuild(object):
else:
files[files.index(file)] = '=%s/%s' % (data['maint'], osp.basename(file)[:-8],) # .jobuild is 8 characters
# =maint/pn-pv
- print files
pv = []
for atom in files:
pv.append(self._split_atom(atom)[3])
@@ -86,20 +92,45 @@ class Jobuild(object):
raise 'No matching jobuild found for atom \"%s\"' % atom
return '%(jobtage)s/%(maint)s/%(pn)s/%(pn)s-%(pv)s.jobuild' % data
+class Processor(object):
+ """Jobuild processor"""
+
+ def __init__(self, jobuild, chroot):
+ """
+ @param jobuild: Jobuild to process
+ @type jobuild: L{autotua.jobuild.Jobuild}
+
+ @param chroot: Chroot to use for processing the jobuild
+ @type chroot: L{autotua.chroot.WorkChroot}
+ """
+ self.jobuild = jobuild
+ self.chroot = chroot
+
+ def run_phase(self, phase):
+ """Run the specified phase of the jobuild"""
+ args = {'phase': phase,
+ 'jobuild': self.jobuild.path,
+ 'chroot': self.chroot.dir,}
+ self._msg('RUN_PHASE "%(phase)s" "%(jobuild)s" "%(chroot)s"' % args)
+
def get_var(self, var):
"""
Parse jobuild and get a variable
(yay-something-works function)
"""
- command = 'GET "%s" "%s"' % (var, self.jobuild)
+ args = {'var': var,
+ 'jobuild': self.jobuild.path,}
+ return self._msg('GET_VAR "%(var)s" "%(jobuild)s"' % args)
+
+ def _msg(self, msg):
# Messages goto 3 and then to /dev/tty1
# stderr goes to stdout
# stdout goes to ${LOGFILE}
- process = subprocess.Popen('\"%s\"/bin/jobuild.sh %s 3>&2 2>&1 | tee -a \"%s\"' % (const.AUTOTUA_DIR, command, const.LOGFILE), shell=True, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
+ process = subprocess.Popen('\"%s\"/bin/jobuild.sh %s 3>&2 2>&1 | tee -a \"%s\"' % (const.AUTOTUA_DIR, msg, const.LOGFILE), shell=True, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
process.stdin.write('ping\n')
response = process.stderr.readline()[:-1] # Remove trailing newline
if not response == 'pong':
# FIXME: Custom exceptions
raise 'Communication error: received %s when expecting "pong"' % response
- response = process.stderr.read()
+ response = process.stderr.read()[:-1] # Remove trailing newline
return response