changeset 30:6089d6ec745a

should now have a working flower; will test when i get internets again
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 31 May 2011 07:29:15 -0700
parents e0cc2fae92bd
children f6b768417d27
files buttercup/buttercup.py buttercup/source.py
diffstat 2 files changed, 41 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/buttercup/buttercup.py	Mon May 30 21:26:50 2011 -0700
+++ b/buttercup/buttercup.py	Tue May 31 07:29:15 2011 -0700
@@ -2,6 +2,12 @@
 the flower blooming to k0s.org
 """
 
+import os
+try:
+    from subprocess import check_call as call
+except ImportError:
+    from subprocess import call
+
 class Buttercup(object):
 
     # k0sware software
@@ -26,10 +32,28 @@
               'webob_view',
               'wordstream']
 
-    def __init__(self):
+    def __init__(self, srcdir):
+        self.srcdir = srcdir
         sources = {'hg': ['%s/%s' % (self.HG, package)
                           for package in self.PACKAGES ]}
         sources['git'] = ['git://github.com/mozilla/toolbox.git']
 
-    
+    def install(self):
+        """install all software needed for this flower"""
+        source_objs = source.sources(self.sources, srcdir=self.srcdir)
+        for source_obj in source_objs:
+            source_obj() # clone/update the software
 
+    def setup(self, source_objs=None):
+        """setup python packages for development"""
+        if source_objs is None:
+            source_objs = source.sources(self.sources, srcdir=self.srcdir)
+        for source_obj in source_objs:            
+            if os.path.exists(os.path.join(source_obj.directory(), 'setup.py')):
+                call(['python', 'setup.py', 'develop'], cwd=source_obj.directory())
+
+    def deploy(self):
+        self.install()
+        self.setup()
+
+    __call__ = deploy
--- a/buttercup/source.py	Mon May 30 21:26:50 2011 -0700
+++ b/buttercup/source.py	Tue May 31 07:29:15 2011 -0700
@@ -1,7 +1,11 @@
+"""
+VCS sources for the flower project
+"""
+
 import os
 try:
     from subprocess import check_call as call
-except:
+except ImportError:
     from subprocess import call
 
 class Source(object):
@@ -20,7 +24,11 @@
 
     def update(self):
         raise NotImplementedError("`Source` is an abstract base class")
-    
+
+    def __call__(self):
+        """convenience wrapper to update"""
+        self.update()
+        
 
 class HgSource(Source):
     """mercurial source"""
@@ -37,8 +45,6 @@
             call(['hg', 'clone', self.uri], cwd=self.srcdir)
             # TODO: add a more intelligent .hg/hgrc
 
-    __call__ = update
-
 
 class GitSource(Source):
 
@@ -60,9 +66,13 @@
             call(['git', 'clone', self.uri], cwd=self.srcdir)
             # TODO: add a more intelligent .git/config
 
-    __call__ = update
 
 def sources(source_dict, **kwargs):
+    """
+    return source objects from a dict:
+    {'hg': ['http://k0s.org/hg/pyloader'],
+     'git': ['git://github.com/mozilla/toolbox.git']}
+    """
     retval = []
     for repo_type, sources in source_dict.items():
         if repo_type == 'hg':