Merge branch 'develop' into dev_graphviz
This commit is contained in:
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
||||
# This file has been auto-generated.
|
||||
# All changes will be lost, see Projectfile.
|
||||
#
|
||||
# Updated at 2017-08-11 10:27:25.096304
|
||||
# Updated at 2017-09-30 10:24:51.699716
|
||||
|
||||
PACKAGE ?= bonobo
|
||||
PYTHON ?= $(shell which python)
|
||||
|
||||
@ -40,7 +40,8 @@ def _install_requirements(requirements):
|
||||
importlib.reload(site)
|
||||
|
||||
|
||||
def read(filename, module, install=False, quiet=False, verbose=False):
|
||||
def read(filename, module, install=False, quiet=False, verbose=False, env=None):
|
||||
import re
|
||||
import runpy
|
||||
from bonobo import Graph, settings
|
||||
|
||||
@ -50,6 +51,12 @@ def read(filename, module, install=False, quiet=False, verbose=False):
|
||||
if verbose:
|
||||
settings.DEBUG.set(True)
|
||||
|
||||
if env:
|
||||
quote_killer = re.compile('["\']')
|
||||
for e in env:
|
||||
var_name, var_value = e.split('=')
|
||||
os.environ[var_name] = quote_killer.sub('', var_value)
|
||||
|
||||
if filename:
|
||||
if os.path.isdir(filename):
|
||||
if install:
|
||||
@ -89,8 +96,8 @@ def read(filename, module, install=False, quiet=False, verbose=False):
|
||||
return graph, plugins, services
|
||||
|
||||
|
||||
def execute(filename, module, install=False, quiet=False, verbose=False):
|
||||
graph, plugins, services = read(filename, module, install, quiet, verbose)
|
||||
def execute(filename, module, install=False, quiet=False, verbose=False, env=None):
|
||||
graph, plugins, services = read(filename, module, install, quiet, verbose, env)
|
||||
|
||||
return bonobo.run(
|
||||
graph,
|
||||
@ -112,4 +119,5 @@ def register(parser):
|
||||
verbosity_group.add_argument('--quiet', '-q', action='store_true')
|
||||
verbosity_group.add_argument('--verbose', '-v', action='store_true')
|
||||
parser.add_argument('--install', '-I', action='store_true')
|
||||
parser.add_argument('--env', '-e', action='append')
|
||||
return execute
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
-e .[dev]
|
||||
alabaster==0.7.10
|
||||
arrow==0.10.0
|
||||
babel==2.4.0
|
||||
babel==2.5.1
|
||||
binaryornot==0.4.4
|
||||
certifi==2017.7.27.1
|
||||
chardet==3.0.4
|
||||
@ -10,7 +10,7 @@ cookiecutter==1.5.1
|
||||
coverage==4.4.1
|
||||
docutils==0.14
|
||||
future==0.16.0
|
||||
idna==2.5
|
||||
idna==2.6
|
||||
imagesize==0.7.1
|
||||
jinja2-time==0.2.0
|
||||
jinja2==2.9.6
|
||||
@ -21,13 +21,13 @@ pygments==2.2.0
|
||||
pytest-cov==2.5.1
|
||||
pytest-sugar==0.8.0
|
||||
pytest-timeout==1.2.0
|
||||
pytest==3.2.1
|
||||
pytest==3.2.2
|
||||
python-dateutil==2.6.1
|
||||
pytz==2017.2
|
||||
requests==2.18.3
|
||||
six==1.10.0
|
||||
requests==2.18.4
|
||||
six==1.11.0
|
||||
snowballstemmer==1.2.1
|
||||
sphinx==1.6.3
|
||||
sphinx==1.6.4
|
||||
sphinxcontrib-websupport==1.0.1
|
||||
termcolor==1.1.0
|
||||
urllib3==1.22
|
||||
|
||||
@ -6,15 +6,15 @@ chardet==3.0.4
|
||||
colorama==0.3.9
|
||||
docker-pycreds==0.2.1
|
||||
docker==2.3.0
|
||||
fs==2.0.7
|
||||
idna==2.5
|
||||
fs==2.0.11
|
||||
idna==2.6
|
||||
packaging==16.8
|
||||
pbr==3.1.1
|
||||
psutil==5.2.2
|
||||
psutil==5.3.1
|
||||
pyparsing==2.2.0
|
||||
pytz==2017.2
|
||||
requests==2.18.3
|
||||
six==1.10.0
|
||||
stevedore==1.25.0
|
||||
requests==2.18.4
|
||||
six==1.11.0
|
||||
stevedore==1.27.0
|
||||
urllib3==1.22
|
||||
websocket-client==0.44.0
|
||||
|
||||
@ -1,26 +1,27 @@
|
||||
-e .[jupyter]
|
||||
appnope==0.1.0
|
||||
bleach==2.0.0
|
||||
bleach==2.1
|
||||
decorator==4.1.2
|
||||
entrypoints==0.2.3
|
||||
html5lib==0.999999999
|
||||
ipykernel==4.6.1
|
||||
ipython-genutils==0.2.0
|
||||
ipython==6.1.0
|
||||
ipywidgets==6.0.0
|
||||
jedi==0.10.2
|
||||
ipython==6.2.1
|
||||
ipywidgets==6.0.1
|
||||
jedi==0.11.0
|
||||
jinja2==2.9.6
|
||||
jsonschema==2.6.0
|
||||
jupyter-client==5.1.0
|
||||
jupyter-console==5.1.0
|
||||
jupyter-console==5.2.0
|
||||
jupyter-core==4.3.0
|
||||
jupyter==1.0.0
|
||||
markupsafe==1.0
|
||||
mistune==0.7.4
|
||||
nbconvert==5.2.1
|
||||
nbformat==4.3.0
|
||||
notebook==5.0.0
|
||||
nbconvert==5.3.1
|
||||
nbformat==4.4.0
|
||||
notebook==5.1.0
|
||||
pandocfilters==1.4.2
|
||||
parso==0.1.0
|
||||
pexpect==4.2.1
|
||||
pickleshare==0.7.4
|
||||
prompt-toolkit==1.0.15
|
||||
@ -28,13 +29,13 @@ ptyprocess==0.5.2
|
||||
pygments==2.2.0
|
||||
python-dateutil==2.6.1
|
||||
pyzmq==16.0.2
|
||||
qtconsole==4.3.0
|
||||
qtconsole==4.3.1
|
||||
simplegeneric==0.8.1
|
||||
six==1.10.0
|
||||
six==1.11.0
|
||||
terminado==0.6
|
||||
testpath==0.3.1
|
||||
tornado==4.5.1
|
||||
tornado==4.5.2
|
||||
traitlets==4.3.2
|
||||
wcwidth==0.1.7
|
||||
webencodings==0.5.1
|
||||
widgetsnbextension==2.0.0
|
||||
widgetsnbextension==2.0.1
|
||||
|
||||
@ -3,14 +3,14 @@ appdirs==1.4.3
|
||||
certifi==2017.7.27.1
|
||||
chardet==3.0.4
|
||||
colorama==0.3.9
|
||||
fs==2.0.7
|
||||
idna==2.5
|
||||
fs==2.0.11
|
||||
idna==2.6
|
||||
packaging==16.8
|
||||
pbr==3.1.1
|
||||
psutil==5.2.2
|
||||
psutil==5.3.1
|
||||
pyparsing==2.2.0
|
||||
pytz==2017.2
|
||||
requests==2.18.3
|
||||
six==1.10.0
|
||||
stevedore==1.25.0
|
||||
requests==2.18.4
|
||||
six==1.11.0
|
||||
stevedore==1.27.0
|
||||
urllib3==1.22
|
||||
|
||||
@ -3,6 +3,7 @@ import runpy
|
||||
import sys
|
||||
from unittest.mock import patch
|
||||
|
||||
import pathlib
|
||||
import pkg_resources
|
||||
import pytest
|
||||
|
||||
@ -96,3 +97,29 @@ def test_version(runner, capsys):
|
||||
out = out.strip()
|
||||
assert out.startswith('bonobo ')
|
||||
assert __version__ in out
|
||||
|
||||
|
||||
@all_runners
|
||||
def test_run_with_env(runner, capsys):
|
||||
runner('run', '--quiet',
|
||||
str(pathlib.Path(os.path.dirname(__file__),
|
||||
'util', 'get_passed_env.py')),
|
||||
'--env', 'ENV_TEST_NUMBER=123', '--env', 'ENV_TEST_USER=cwandrews',
|
||||
'--env', "ENV_TEST_STRING='my_test_string'")
|
||||
out, err = capsys.readouterr()
|
||||
out = out.split('\n')
|
||||
assert out[0] == 'cwandrews'
|
||||
assert out[1] == '123'
|
||||
assert out[2] == 'my_test_string'
|
||||
|
||||
|
||||
@all_runners
|
||||
def test_run_module_with_env(runner, capsys):
|
||||
runner('run', '--quiet', '-m', 'tests.util.get_passed_env',
|
||||
'--env', 'ENV_TEST_NUMBER=123', '--env', 'ENV_TEST_USER=cwandrews',
|
||||
'--env', "ENV_TEST_STRING='my_test_string'")
|
||||
out, err = capsys.readouterr()
|
||||
out = out.split('\n')
|
||||
assert out[0] == 'cwandrews'
|
||||
assert out[1] == '123'
|
||||
assert out[2] == 'my_test_string'
|
||||
|
||||
22
tests/util/get_passed_env.py
Normal file
22
tests/util/get_passed_env.py
Normal file
@ -0,0 +1,22 @@
|
||||
import os
|
||||
|
||||
from bonobo import Graph
|
||||
|
||||
|
||||
def extract():
|
||||
env_test_user = os.getenv('ENV_TEST_USER')
|
||||
env_test_number = os.getenv('ENV_TEST_NUMBER')
|
||||
env_test_string = os.getenv('ENV_TEST_STRING')
|
||||
return env_test_user, env_test_number, env_test_string
|
||||
|
||||
|
||||
def load(s: str):
|
||||
print(s)
|
||||
|
||||
|
||||
graph = Graph(extract, load)
|
||||
|
||||
if __name__ == '__main__':
|
||||
from bonobo import run
|
||||
|
||||
run(graph)
|
||||
Reference in New Issue
Block a user