diff options
Diffstat (limited to 'slave/autotua/jobuild/__init__.py')
-rw-r--r-- | slave/autotua/jobuild/__init__.py | 41 |
1 files changed, 36 insertions, 5 deletions
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 |