changeset 42:6981dcad3b2c

--list-factories now works
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Jan 2011 11:24:19 -0800
parents 42ef457708de
children 19d555001292
files autobot/template.py
diffstat 1 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/autobot/template.py	Mon Jan 10 11:22:10 2011 -0800
+++ b/autobot/template.py	Mon Jan 10 11:24:19 2011 -0800
@@ -18,6 +18,18 @@
 except ImportError:
     from subprocess import call
 
+def factory_descriptions():
+    """print factory descriptions"""
+
+    buffer = StringIO()
+    print >> buffer, 'Factories:\n'
+    for key in sorted(factories.keys()):
+        print >> buffer, '%s:' % key
+        print >> buffer, getattr(factories[key], '__doc__', '').strip()
+        print >> buffer
+    return buffer.getvalue()
+
+
 class AutobotMasterTemplate(MakeItSoTemplate):
     name = 'autobot-master'
     description = 'template for the autotools buildbot master'
@@ -27,21 +39,12 @@
             Variable('slaveport', 'port to talk to slaves on', default=9010, cast=int),
             Variable('htmlport', 'port for waterfall display', default=8010, cast=int)]
 
-    def factory_descriptions(self):
-        buffer = StringIO()
-        print >> buffer, 'Factories:\n'
-        for key in sorted(factories.keys()):
-            print >> buffer, '%s:' % key
-            print >> buffer, getattr(factories[key], '__doc__', '').strip()
-            print >> buffer
-        return buffer.getvalue()
-
     def pre(self, variables):
         factory = variables.get('factory')
         if factory:
             assert factory in factories, 'Factory must be one of: ' % ', '.join(factories.keys())
         elif self.interactive:
-            print self.factory_descriptions()
+            print factory_descriptions()
             sys.stdout.write('Enter factory: ')
             factory = raw_input()
             assert factory in factories, 'Factory must be one of: ' % ', '.join(factories.keys())
@@ -118,7 +121,7 @@
 
         # list the factories
         if options._list_factories:
-            print self.template.factory_descriptions()
+            print factory_descriptions()
             parser.exit()
 
         # call the parent