Merge pull request #258 from benrudolph/br/return-results
Tweaks to ETLCommand command
This commit is contained in:
@ -41,18 +41,17 @@ class ETLCommand(BaseCommand):
|
|||||||
def get_services(self):
|
def get_services(self):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def get_strategy(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def info(self, *args, **kwargs):
|
def info(self, *args, **kwargs):
|
||||||
self.logger.info(*args, **kwargs)
|
self.logger.info(*args, **kwargs)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def run(self, *args, **options):
|
||||||
_stdout_backup, _stderr_backup = self.stdout, self.stderr
|
results = []
|
||||||
|
|
||||||
self.stdout = OutputWrapper(ConsoleOutputPlugin._stdout, ending=CLEAR_EOL + '\n')
|
|
||||||
self.stderr = OutputWrapper(ConsoleOutputPlugin._stderr, ending=CLEAR_EOL + '\n')
|
|
||||||
self.stderr.style_func = lambda x: Fore.LIGHTRED_EX + Back.RED + '!' + Style.RESET_ALL + ' ' + x
|
|
||||||
|
|
||||||
with bonobo.parse_args(options) as options:
|
with bonobo.parse_args(options) as options:
|
||||||
services = self.get_services()
|
services = self.get_services()
|
||||||
|
strategy = self.get_strategy()
|
||||||
graph_coll = self.get_graph(*args, **options)
|
graph_coll = self.get_graph(*args, **options)
|
||||||
|
|
||||||
if not isinstance(graph_coll, GeneratorType):
|
if not isinstance(graph_coll, GeneratorType):
|
||||||
@ -61,8 +60,20 @@ class ETLCommand(BaseCommand):
|
|||||||
for i, graph in enumerate(graph_coll):
|
for i, graph in enumerate(graph_coll):
|
||||||
assert isinstance(graph, bonobo.Graph), 'Invalid graph provided.'
|
assert isinstance(graph, bonobo.Graph), 'Invalid graph provided.'
|
||||||
print(term.lightwhite('{}. {}'.format(i + 1, graph.name)))
|
print(term.lightwhite('{}. {}'.format(i + 1, graph.name)))
|
||||||
result = bonobo.run(graph, services=services)
|
result = bonobo.run(graph, services=services, strategy=strategy)
|
||||||
|
results.append(result)
|
||||||
print(term.lightblack(' ... return value: ' + str(result)))
|
print(term.lightblack(' ... return value: ' + str(result)))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
_stdout_backup, _stderr_backup = self.stdout, self.stderr
|
||||||
|
|
||||||
|
self.stdout = OutputWrapper(ConsoleOutputPlugin._stdout, ending=CLEAR_EOL + '\n')
|
||||||
|
self.stderr = OutputWrapper(ConsoleOutputPlugin._stderr, ending=CLEAR_EOL + '\n')
|
||||||
|
self.stderr.style_func = lambda x: Fore.LIGHTRED_EX + Back.RED + '!' + Style.RESET_ALL + ' ' + x
|
||||||
|
|
||||||
|
self.run(*args, **kwargs)
|
||||||
|
|
||||||
self.stdout, self.stderr = _stdout_backup, _stderr_backup
|
self.stdout, self.stderr = _stdout_backup, _stderr_backup
|
||||||
|
|||||||
Reference in New Issue
Block a user