changeset 40:e6c7a4cf2b40

stub out setting properties; not sure if this is the way to do it or not
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Jan 2011 10:57:44 -0800
parents 98fa7d1a7b1d
children 42ef457708de
files autobot/process/factory.py
diffstat 1 files changed, 26 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/autobot/process/factory.py	Mon Jan 10 09:38:40 2011 -0800
+++ b/autobot/process/factory.py	Mon Jan 10 10:57:44 2011 -0800
@@ -1,11 +1,19 @@
 from autobot.steps import CreateVirtualenv
 from buildbot.process.factory import BuildFactory
+from buildbot.steps.shell import SetProperty
 from buildbot.steps.shell import ShellCommand
+from buildbot.steps.shell import WithProperties
 
 """
 generic factories 
 """
 
+def find(*args):
+  """
+  returns a command to echo the found file
+  """
+  return ' || '.join(['ls -d %s 2> /dev/null' % arg for arg in args])
+
 class VirtualenvFactory(BuildFactory):
   """
   create a virtualenv
@@ -22,30 +30,42 @@
     self.addStep(ShellCommand(command=['mkdir', 'src'],
                               workdir=name))
     # TODO: set properities:
+    # - virtualenv location
+    # - scripts location
     # - python location
-    # - virtualenv location
+    self.addStep(SetProperty(property='virtualenv',
+                             command=['pwd'],
+                             workdir=name))
+    self.addStep(SetProperty(property='scripts',
+                             command=find('Scripts', 'bin'),
+                             workdir=name))
+    self.addStep(SetProperty(property='python',
+                             workdir=WithProperties('%(virtualenv)s/%(scripts)s'),
+                             command=find('python', 'python.exe'))
 
     # clone hg repositories
     for hg_source in hg_sources:
       self.addStep(ShellCommand(command=['hg', 'clone', hg_source],
-                                workdir=name+'/src'))
+                                workdir=name+'/src',
+                                haltOnFailure=True))
 
     # clone the git repositories
     for git_source in git_sources:
       self.addStep(ShellCommand(command=['git', 'clone', git_source],
-                                workdir=name+'/src'))
+                                workdir=name+'/src',
+                                haltOnFailure=True))
 
 class PythonSourceFactory(VirtualenvFactory):
   """
   setup several python packages
   """
 
-  def __init__(self, name='env', hg_sources=()):
+  def __init__(self, name='env', hg_sources=(), git_sources=()):
 
     # setup the environment
-    VirtualenvFactory.__init__(self, name=name, hg_sources=hg_sources)
+    VirtualenvFactory.__init__(self, name=name, hg_sources=hg_sources, git_sources=git_sources)
 
-    # install the packages
+    # install the packages [TODO]
 
 
 # python sources: