aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-08-30 20:11:28 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-08-30 20:11:28 +0530
commitca2cf37c259a06eca1d02234631bc9046ceb5da0 (patch)
tree6f977ed509de9f538cc46d0f7da14054cfedd6eb /slave/autotua
parentMake the slave system-installable and configurable (diff)
downloadautotua-ca2cf37c259a06eca1d02234631bc9046ceb5da0.tar.gz
autotua-ca2cf37c259a06eca1d02234631bc9046ceb5da0.tar.bz2
autotua-ca2cf37c259a06eca1d02234631bc9046ceb5da0.zip
Numerous small bugfixes for commit 5dc25d
* Compatibility with git-1.6 (git-* commands are gone) * atexit.register() needs a function *reference* you dope :) * job_data['atoms'] is no longer an array, but is a space-separated string * jobuild.name -> jobuild.atom (a while ago) * Replace string exceptions with Exception(); for compatibility with unicode objects sent by django-1.0 * jobtagedir is different when using a chroot and not (duh)
Diffstat (limited to 'slave/autotua')
-rw-r--r--slave/autotua/__init__.py6
-rw-r--r--slave/autotua/daemon/__init__.py2
-rw-r--r--slave/autotua/jobuild/__init__.py16
-rw-r--r--slave/autotua/sync/__init__.py13
4 files changed, 19 insertions, 18 deletions
diff --git a/slave/autotua/__init__.py b/slave/autotua/__init__.py
index 7d5ef6c..ef67de3 100644
--- a/slave/autotua/__init__.py
+++ b/slave/autotua/__init__.py
@@ -42,7 +42,7 @@ class Job:
self.atoms = job_data['atoms']
self.jobuilds = []
self.chroot = chroot.WorkChroot(self.jobdir, self.stage.filename)
- atexit.register(self.tidy())
+ atexit.register(self.tidy)
def __repr__(self):
return '<%s: %s>' % (self.name, 'Job object')
@@ -99,7 +99,7 @@ class Job:
print 'Setup the chroot for usage...'
self.chroot.setup()
# Create jobuild objects for parsing
- for atom in self.atoms:
+ for atom in self.atoms.split():
self.jobuilds.append(jobuild.Jobuild(self.jobtagedir, atom))
print 'Fetch jobuild SRC_URI and hardlink/copy into chroot'
self._setup_jobfiles()
@@ -108,7 +108,7 @@ class Job:
processor = jobuild.Processor(None, self.chroot)
for jbld in self.jobuilds:
processor.jobuild = jbld
- print 'Running jobuild "%s"' % jbld.name
+ print 'Running jobuild "%s"' % jbld.atom
processor.run_phase('all')
def tidy(self):
diff --git a/slave/autotua/daemon/__init__.py b/slave/autotua/daemon/__init__.py
index a5e4f86..9e52fb0 100644
--- a/slave/autotua/daemon/__init__.py
+++ b/slave/autotua/daemon/__init__.py
@@ -44,7 +44,7 @@ class Spawn(object):
response = process.stderr.readline()
if not response == 'pong\n':
# FIXME: Custom exceptions
- raise 'Communication error: received %s when expecting "pong"' % response
+ raise Exception('Communication error: received %s when expecting "pong"' % response)
process.stdin.write(self.workdir+'\n')
process.stdin.write(self.jobtagedir+'\n')
return process
diff --git a/slave/autotua/jobuild/__init__.py b/slave/autotua/jobuild/__init__.py
index 54d3ca0..93732b6 100644
--- a/slave/autotua/jobuild/__init__.py
+++ b/slave/autotua/jobuild/__init__.py
@@ -38,15 +38,15 @@ class Jobuild(object):
parts = regex.findall(atom)
if not parts:
# FIXME: Custom exceptions
- raise 'Invalid atom %s' % atom
+ raise Exception('Invalid atom %s' % atom)
parts = parts[0]
if parts[3] and not parts[4]:
# FIXME: Custom exceptions
- raise 'Invalid atom %s' % atom
+ raise Exception('Invalid atom %s' % atom)
parts = (parts[0], parts[1], parts[2], parts[4],)
if (parts[0] and not parts[3]) or (parts[3] and not parts[0]):
# FIXME: Custom exceptions
- raise 'Invalid atom %s' % atom
+ raise Exception('Invalid atom %s' % atom)
return parts
def _get_all_pv_sorted(self, data):
@@ -80,7 +80,7 @@ class Jobuild(object):
if pv[-1] >= data['pv']:
data['pv'] = pv[-1]
else:
- raise 'No matching jobuild found for atom \"%s\"' % atom
+ raise Exception('No matching jobuild found for atom \"%s\"' % atom)
elif data['op'] == '<=':
pv = self._get_all_pv_sorted(data)
pv.reverse()
@@ -89,7 +89,7 @@ class Jobuild(object):
data['pv'] = i
break
if i == pv[-1]: # If it's the last pv..
- raise 'No matching jobuild found for atom \"%s\"' % atom
+ raise Exception('No matching jobuild found for atom \"%s\"' % atom)
return '%(maint)s/%(pn)s/%(pn)s-%(pv)s.jobuild' % data
class Processor(object):
@@ -130,17 +130,19 @@ class Processor(object):
def _msg(self, msg):
chroot = None
workdir = config.AUTOTUA_DIR
+ jobtagedir = self.jobuild.jobtagedir
if self.chroot:
chroot = self.chroot.chrootdir
workdir = config.CHAUTOTUA_DIR
- proc = daemon.Spawn(chroot, self.jobuild.jobtagedir, workdir, '\"%s\"/bin/jobuild.sh %s' % (workdir, msg))
+ jobtagedir = config.CHAUTOTUA_DIR+'/jobtage'
+ proc = daemon.Spawn(chroot, jobtagedir, workdir, '\"%s\"/bin/jobuild.sh %s' % (workdir, msg))
# XXX: This waits for process to close stderr.
# Replace with a loop during daemonisation
response = proc.process.stderr.read()[:-1] # Remove trailing newline
returncode = proc.process.returncode
if returncode and returncode < 0:
# FIXME: Custom exceptions
- raise 'Daemon died with exit code \'%s\'' % -returncode
+ raise Exception('Daemon died with exit code \'%s\'' % -returncode)
return response
class Resolver(object):
diff --git a/slave/autotua/sync/__init__.py b/slave/autotua/sync/__init__.py
index 7ad356f..2a57651 100644
--- a/slave/autotua/sync/__init__.py
+++ b/slave/autotua/sync/__init__.py
@@ -62,11 +62,11 @@ class Syncer(object):
elif self.scheme in ['git', 'bzr']:
is_repo_cmd = None
if self.scheme == 'git':
- is_repo_cmd = 'git-rev-parse'
+ is_repo_cmd = 'git rev-parse'
elif self.scheme == 'bzr':
is_repo_cmd = 'bzr info'
else:
- raise 'Unknown scm: "%s"' % self.scheme
+ raise Exception('Unknown scm: "%s"' % self.scheme)
result = subprocess.Popen('cd "%s"; %s' % (self.destdir, is_repo_cmd), shell=True)
returncode = result.wait()
if returncode != 0:
@@ -81,8 +81,7 @@ class Syncer(object):
"""
if osp.exists(self.destdir):
if not osp.isdir(self.destdir):
- # FIXME: Custom exceptions
- raise '"%s" exists and is not a directory' % self.destdir
+ raise Exception('"%s" exists and is not a directory' % self.destdir)
result = self._is_repo()
if result == ONLY_SYNC:
self.command.run('init')
@@ -92,7 +91,7 @@ class Syncer(object):
shutil.rmtree(self.destdir)
self.command.run('init')
else:
- raise 'Erm. I did not expect this. DIE DIE DIE.'
+ raise Exception('Erm. I did not expect this. DIE DIE DIE.')
else:
if not osp.exists(osp.dirname(self.destdir)):
# Create parents
@@ -130,14 +129,14 @@ class Command(object):
if action == 'sync':
return cmd+'git config remote.origin.url "$URI";git fetch -f -u origin master:master'
elif self.scheme == 'git-export': # export self.rev
- return 'git-archive --prefix="%s/" --remote="%s" "%s" | tar x -C "%s"' % \
+ return 'git archive --prefix="%s/" --remote="%s" "%s" | tar x -C "%s"' % \
(osp.basename(self.destdir), self.uri, self.rev, osp.dirname(self.destdir))
elif self.scheme == 'rsync': # rsync, delete
return 'rsync -a --delete-after "%s" "%s"' % (self.uri, self.destdir)
elif self.scheme == 'rsync-nc': # rsync, no-clobber
return 'rsync -a "%s" "%s"' % (self.uri, self.destdir)
else:
- raise "Unknown scheme: %s" % self.scheme
+ raise Exception("Unknown scheme: %s" % self.scheme)
def run(self, action):
"""Run a sync command"""