diff --git a/bonobo/commands/init.py b/bonobo/commands/init.py index a937041..de55251 100644 --- a/bonobo/commands/init.py +++ b/bonobo/commands/init.py @@ -1,4 +1,4 @@ -def execute(name): +def execute(name, branch): try: from cookiecutter.main import cookiecutter except ImportError as exc: @@ -7,10 +7,12 @@ def execute(name): ) from exc return cookiecutter( - 'https://github.com/python-bonobo/cookiecutter-bonobo.git', extra_context={'name': name}, no_input=True + 'https://github.com/python-bonobo/cookiecutter-bonobo.git', extra_context={'name': name}, no_input=True, + checkout=branch ) def register(parser): parser.add_argument('name') + parser.add_argument('--branch', '-b', default='master') return execute diff --git a/bonobo/commands/run.py b/bonobo/commands/run.py index c32e394..cb3c62e 100644 --- a/bonobo/commands/run.py +++ b/bonobo/commands/run.py @@ -3,7 +3,7 @@ import os DEFAULT_SERVICES_FILENAME = '_services.py' DEFAULT_SERVICES_ATTR = 'get_services' -DEFAULT_GRAPH_FILENAME = '__main__.py' +DEFAULT_GRAPH_FILENAMES = ('__main__.py', 'main.py',) DEFAULT_GRAPH_ATTR = 'get_graph' @@ -49,7 +49,14 @@ def execute(filename, module, install=False, quiet=False, verbose=False): pip.utils.pkg_resources = importlib.reload(pip.utils.pkg_resources) import site importlib.reload(site) - filename = os.path.join(filename, DEFAULT_GRAPH_FILENAME) + + pathname = filename + for filename in DEFAULT_GRAPH_FILENAMES: + filename = os.path.join(pathname, filename) + if os.path.exists(filename): + break + if not os.path.exists(filename): + raise IOError('Could not find entrypoint (candidates: {}).'.format(', '.join(DEFAULT_GRAPH_FILENAMES))) elif install: raise RuntimeError('Cannot --install on a file (only available for dirs containing requirements.txt).') context = runpy.run_path(filename, run_name='__bonobo__')