From ebd032e525df60b81ab2a7dd294bfdfd35436fd9 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Wed, 10 Jan 2018 08:25:29 +0100 Subject: [PATCH] Be more informative on command failures --- djangocms_installer/django/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 66e7ae2..568b28a 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -57,8 +57,13 @@ def create_project(config_data): cmd_args = start_cmd + ['startproject'] + args if config_data.verbose: sys.stdout.write('Project creation command: {0}\n'.format(' '.join(cmd_args))) - output = subprocess.check_output(cmd_args) - sys.stdout.write(output.decode('utf-8')) + try: + output = subprocess.check_output(cmd_args, stderr=subprocess.STDOUT) + sys.stdout.write(output.decode('utf-8')) + except subprocess.CalledProcessError as e: # pragma: no cover + if config_data.verbose: + sys.stdout.write(e.output.decode('utf-8')) + raise def _detect_migration_layout(vars, apps): @@ -401,7 +406,9 @@ def setup_database(config_data): command, env=env, stderr=subprocess.STDOUT ) sys.stdout.write(output.decode('utf-8')) - except subprocess.CalledProcessError: + except subprocess.CalledProcessError as e: # pragma: no cover + if config_data.verbose: + sys.stdout.write(e.output.decode('utf-8')) raise if not config_data.no_user: