patman: Tidy up the start-up code
Much of this was written before the other Python tools and they have
evolved. Make a few updates:
- Rather than calling sys.exit(), return the exit code from the control
module and use it in __main__
- Set up tout as it is used in some places
- We now have quite a few tests, so update the comment about that
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/patman/control.py b/tools/patman/control.py
index 990e07f..a050bd2 100644
--- a/tools/patman/control.py
+++ b/tools/patman/control.py
@@ -280,18 +280,18 @@
args.ignore_bad_tags = True
send(args)
- # Check status of patches in patchwork
- elif args.cmd == 'status':
- ret_code = 0
- try:
+ ret_code = 0
+ try:
+ # Check status of patches in patchwork
+ if args.cmd == 'status':
patchwork_status(args.branch, args.count, args.start, args.end,
args.dest_branch, args.force, args.show_comments,
args.patchwork_url)
- except Exception as exc:
- terminal.tprint(f'patman: {type(exc).__name__}: {exc}',
- colour=terminal.Color.RED)
- if args.debug:
- print()
- traceback.print_exc()
- ret_code = 1
- sys.exit(ret_code)
+ except Exception as exc:
+ terminal.tprint(f'patman: {type(exc).__name__}: {exc}',
+ colour=terminal.Color.RED)
+ if args.debug:
+ print()
+ traceback.print_exc()
+ ret_code = 1
+ return ret_code