|
@@ -3,29 +3,28 @@ Frank can be configured using the following yaml::
|
|
|
.frank.yml
|
|
|
|
|
|
commads:
|
|
|
- - build
|
|
|
- test
|
|
|
- - publish
|
|
|
- deploy
|
|
|
+ - publish
|
|
|
|
|
|
+ newtag:
|
|
|
+ - python:
|
|
|
+ - frank.actions:detect_new_tag
|
|
|
|
|
|
deploy:
|
|
|
- cmd
|
|
|
- runif:
|
|
|
- test
|
|
|
- newtag
|
|
|
-
|
|
|
- newtag:
|
|
|
- - python:
|
|
|
- - frank.actions:detect_new_tag
|
|
|
-
|
|
|
- publish:
|
|
|
+
|
|
|
+ publish:
|
|
|
- shell:
|
|
|
- - cd docs; make html
|
|
|
+ - cd docs; make html
|
|
|
- python:
|
|
|
- - frank.actions:recursive_copy
|
|
|
+ - frank.actions:recursive_copy
|
|
|
|
|
|
-The sections commands is a simple list of command you would like to define.
|
|
|
+The sections commands is a simple list of command you would
|
|
|
+like to define.
|
|
|
This section is optional. It's main purpose is for you to decalre
|
|
|
which commands frank should execute upon recieving a load.
|
|
|
|
|
@@ -118,8 +117,9 @@ from flask import Flask, request, abort
|
|
|
import conf
|
|
|
from shell import Shell
|
|
|
from collections import OrderedDict, namedtuple
|
|
|
+import importlib
|
|
|
|
|
|
-PythonCode = namedtupe('PythonCode', path, args, kwargs, code)
|
|
|
+PythonCode = namedtuple('PythonCode', ['path', 'args', 'kwargs', 'code'])
|
|
|
|
|
|
def override_run(self, command, **kwargs):
|
|
|
"""
|
|
@@ -208,6 +208,7 @@ def report_failure(results):
|
|
|
|
|
|
def run_action(axn):
|
|
|
results = []
|
|
|
+ # run shell or python callable object without arguments
|
|
|
if isinstance(axn, list):
|
|
|
|
|
|
if axn[0] == 'shell':
|
|
@@ -221,11 +222,12 @@ def run_action(axn):
|
|
|
if axn[0] == 'python':
|
|
|
for func in axn[1:]:
|
|
|
mod, f = func.split(':')
|
|
|
- mod = importlib.import(mod)
|
|
|
+ mod = importlib.import_module(mod)
|
|
|
f = getattr(mod, f)
|
|
|
res = f()
|
|
|
results.append(PythonCode(func, None, None, res))
|
|
|
|
|
|
+ # run shell or python callable object arguments
|
|
|
elif isinstance(axn, OrderedDict):
|
|
|
|
|
|
if 'shell' in axn:
|
|
@@ -237,6 +239,20 @@ def run_action(axn):
|
|
|
sh.run(cmd, **kwargs)
|
|
|
results.append(sh)
|
|
|
|
|
|
+ if 'python' in axn:
|
|
|
+ callables = axn['python']
|
|
|
+ for func in callables:
|
|
|
+ mod, f = func.split(':')
|
|
|
+ mod = importlib.import_module(mod)
|
|
|
+ try:
|
|
|
+ f = getattr(mod, f)
|
|
|
+ res = f()
|
|
|
+ except AttributeError as E:
|
|
|
+ res = E
|
|
|
+
|
|
|
+ results.append(PythonCode(func, None, None, res))
|
|
|
+
|
|
|
+
|
|
|
return results
|
|
|
|
|
|
|