aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'slave/autotua/__init__.py')
-rw-r--r--slave/autotua/__init__.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/slave/autotua/__init__.py b/slave/autotua/__init__.py
index 601937d..7d5ef6c 100644
--- a/slave/autotua/__init__.py
+++ b/slave/autotua/__init__.py
@@ -9,7 +9,7 @@
import os, shutil, urllib2, atexit
import os.path as osp
import cPickle as pickle
-from autotua import fetch, const, sync, chroot, jobuild
+from autotua import fetch, config, sync, chroot, jobuild
class Jobs:
"""Interface to jobs on the master server that we can do"""
@@ -23,7 +23,7 @@ class Jobs:
(skeleton code atm)
"""
jobs = []
- job_list = pickle.load(urllib2.urlopen(const.AUTOTUA_MASTER+'/slave_api/jobs'))
+ job_list = pickle.load(urllib2.urlopen(config.AUTOTUA_MASTER+'/slave_api/jobs'))
for job_data in job_list:
jobs.append(Job(job_data))
return jobs
@@ -36,7 +36,7 @@ class Job:
self.maint = job_data['maintainer']['username']
self.name = job_data['name']
self.stage = fetch.Fetchable(uri=[job_data['stage']])
- self.jobdir = osp.join(const.WORKDIR, self.maint, self.name)
+ self.jobdir = osp.join(config.WORKDIR, self.maint, self.name)
self.jobtagedir = osp.join(self.jobdir, 'jobtage')
self.jobtagerev = job_data['jobtagerev']
self.atoms = job_data['atoms']
@@ -55,7 +55,7 @@ class Job:
def _setup_jobfiles(self):
job_src = []
action = 'link'
- fetcher = fetch.Fetcher(const.JOBFILE_DIR)
+ fetcher = fetch.Fetcher(config.JOBFILE_DIR)
processor = jobuild.Processor(None, self.chroot)
for jbld in self.jobuilds:
processor.jobuild = jbld
@@ -63,7 +63,7 @@ class Job:
for i in src_uri:
job_src.append(fetch.Fetchable(uri=[i]))
src = fetcher.tarballdir+'/%s'
- dest = self.chroot.chrootdir+const.CHAUTOTUA_DIR+'/jobfiles/%s'
+ dest = self.chroot.chrootdir+config.CHAUTOTUA_DIR+'/jobfiles/%s'
for fetchable in job_src:
fetcher.fetch(fetchable)
src = src % fetchable.filename
@@ -81,14 +81,14 @@ class Job:
# Job metadata stuff
## Get stage3 (if required)
print 'Fetching stage...'
- fetcher = fetch.Fetcher(const.STAGE_DIR)
+ fetcher = fetch.Fetcher(config.STAGE_DIR)
fetcher.fetch(self.stage)
# Sync jobtage tree
print 'Syncing jobtage tree...'
sync.Syncer().sync()
# Export from local jobtage tree
print 'Exporting jobtage tree...'
- sync.Syncer(uri=const.JOBTAGE_DIR, destdir=self.jobtagedir,
+ sync.Syncer(uri=config.JOBTAGE_DIR, destdir=self.jobtagedir,
rev=self.jobtagerev, scheme="git-export").sync()
## Read config, get portage snapshot if required
#self._fetch_portage_snapshot()
@@ -119,4 +119,14 @@ class Job:
# Tidy up before cleaning
self.tidy()
shutil.rmtree(self.jobdir)
- os.removedirs(osp.join(const.WORKDIR, self.maint))
+ os.removedirs(osp.join(config.WORKDIR, self.maint))
+
+if __name__ == "__main__":
+ job = Jobs().getjobs()[0]
+ job.fetch()
+ if os.getuid() == 0:
+ job.prepare()
+ job.run()
+ job.tidy()
+ else:
+ print 'You need to be root to run job.prepare(), job.run() and job.tidy()'