diff options
| author | Simon Glass <sjg@chromium.org> | 2025-04-29 07:22:09 -0600 |
|---|---|---|
| committer | Simon Glass <sjg@chromium.org> | 2025-05-27 10:07:41 +0100 |
| commit | 6e64ae22c2bbb540a8c84193578b8cf0d03f42b9 (patch) | |
| tree | 001f9e802853151d788c64a579c7f9a5e2f240f6 /tools/patman | |
| parent | f5ec4f05f9322bdbfcbff79bfbe2f5f06380ec7d (diff) | |
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>
Diffstat (limited to 'tools/patman')
| -rwxr-xr-x | tools/patman/__main__.py | 8 | ||||
| -rw-r--r-- | tools/patman/control.py | 24 |
2 files changed, 18 insertions, 14 deletions
diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py index db78ea603c2..6aadf767eca 100755 --- a/tools/patman/__main__.py +++ b/tools/patman/__main__.py @@ -15,6 +15,7 @@ our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(our_path, '..')) # Our modules +from u_boot_pylib import tout from patman import cmdline from patman import control from u_boot_pylib import test_util @@ -31,7 +32,9 @@ def run_patman(): if not args.debug: sys.tracebacklimit = 0 - # Run our meagre tests + tout.init(tout.INFO if args.verbose else tout.WARNING) + + # Run our reasonably good tests if args.cmd == 'test': # pylint: disable=C0415 from patman import func_test @@ -46,7 +49,8 @@ def run_patman(): # Process commits, produce patches files, check them, email them else: - control.do_patman(args) + exit_code = control.do_patman(args) + sys.exit(exit_code) if __name__ == "__main__": diff --git a/tools/patman/control.py b/tools/patman/control.py index 990e07f8766..a050bd2f551 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -280,18 +280,18 @@ def do_patman(args): 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 |
