From 3407994e00ddf74fef5f10bbaae1fd1f488a1b51 Mon Sep 17 00:00:00 2001 From: Ben Rudolph Date: Fri, 23 Mar 2018 17:37:11 -0700 Subject: [PATCH] extract run function --- bonobo/contrib/django/commands.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bonobo/contrib/django/commands.py b/bonobo/contrib/django/commands.py index eda6141..b54edd8 100644 --- a/bonobo/contrib/django/commands.py +++ b/bonobo/contrib/django/commands.py @@ -44,13 +44,7 @@ class ETLCommand(BaseCommand): def info(self, *args, **kwargs): self.logger.info(*args, **kwargs) - 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 - + def run(self, *args, **options): with bonobo.parse_args(options) as options: services = self.get_services() graph_coll = self.get_graph(*args, **options) @@ -65,4 +59,13 @@ class ETLCommand(BaseCommand): print(term.lightblack(' ... return value: ' + str(result))) print() + 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