Commits

Jesper Nøhr committed 335af9a

adding everything from the beginning

  • Participants

Comments (0)

Files changed (7)

samples/helloworld.step

+from step.steps.system import RunCommand
+
+steps = [ RunCommand("echo Hello world!"),
+          RunCommand("echo Hello back!"),
+          RunCommand("ls") ]
+# -*- coding: utf-8 -*-
+try:
+    from setuptools import setup, find_packages
+except ImportError:
+    import distribute_setup
+    distribute_setup.use_setuptools()
+    from setuptools import setup, find_packages
+
+import os
+import sys
+
+from step import __version__
+
+setup(
+    name='step',
+    version=__version__,
+    url='http://bitbucket.org/jespern/step/',
+    license='BSD',
+    author='Jesper Noehr',
+    author_email='jesper@noehr.org',
+    description='Performs steps',
+    zip_safe=False,
+    classifiers=[
+        'Environment :: Console',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: BSD License',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Programming Language :: Python :: 2',
+        'Topic :: Utilities',
+    ],
+    platforms='any',
+    packages=find_packages(),
+    include_package_data=True,
+    entry_points={
+        'console_scripts': [
+            'step = step:main',
+        ],
+    },
+)
+import sys
+import getopt
+
+from recipe import Recipe
+
+__version__ = '0.1'
+
+def main(args=sys.argv):
+    opts, args = getopt.getopt(args[1:], 'v')
+    verbose = False
+    
+    if not args:
+        print "Must specify a recipe."
+        sys.exit(1)
+    else:
+        recipe = args[0]
+
+    for opt, val in opts:
+        if opt in ('-v', '--verbose'):
+            verbose = True
+
+    print "Reading recipe", recipe, "..",
+
+    rec = Recipe(recipe)
+
+    print "OK\nRunning recipe .."
+    
+    rec.bake()
+    
+if __name__ == "__main__":
+    main(sys.argv)
+
+class Recipe(object):
+    def __init__(self, fn):
+        self.fn = fn
+        self.retain = {}
+
+        execfile(self.fn, globals(), self.retain)
+
+        self.steps = self.retain.get('steps')
+        
+    def bake(self):
+        for step in self.steps:
+            step.walk()

step/steps/__init__.py

+class Step(object):
+    pass

step/steps/system.py

+import os
+
+from step.steps import Step
+
+class RunCommand(Step):
+    def __init__(self, command=None):
+        self.command = command
+
+    def walk(self):
+        return os.system(self.command)