From 1db0ac2d21662a7b0dc8f951ae91a0335ff3c05d Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 7 Jan 2014 18:10:39 -0800 Subject: Raise traceback on error when using CLI and -debug When --debug is specified to the CLI don't just print the simple error message but actually reraise that error. Change-Id: I616eda8e033342cff7f3412e3a414a7530ef3848 Closes-Bug: #1268202 --- heatclient/shell.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'heatclient/shell.py') diff --git a/heatclient/shell.py b/heatclient/shell.py index 82b05df..9d136a6 100644 --- a/heatclient/shell.py +++ b/heatclient/shell.py @@ -421,12 +421,17 @@ class HelpFormatter(argparse.HelpFormatter): super(HelpFormatter, self).start_section(heading) -def main(): +def main(args=None): try: - HeatShell().main(sys.argv[1:]) + if args is None: + args = sys.argv[1:] + HeatShell().main(args) except Exception as e: - print(strutils.safe_encode(six.text_type(e)), file=sys.stderr) + if '--debug' in args or '-d' in args: + raise + else: + print(strutils.safe_encode(six.text_type(e)), file=sys.stderr) sys.exit(1) if __name__ == "__main__": -- cgit v1.2.1