Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions chirp/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,11 @@ def main(args=None):
try:
radio.sync_in()
radio.save_mmap(options.mmap)
LOG.info("Download successful: %s", options.mmap)
sys.exit(0)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to not exit(0) anywhere and take that default if we fall out the bottom with nothing failing. Just moving the exit(1) into the exception handler would take care of that. That would solve the problem right?

Really, sys.exit() anywhere in the middle of something is a bad pattern (this code is super old) but especially forcing exit success in the middle is pretty weird.

except Exception as e:
LOG.exception(e)
sys.exit(1)
sys.exit(1)

if options.upload_mmap:
if not issubclass(rclass, chirp_common.CloneModeRadio):
Expand All @@ -394,9 +396,10 @@ def main(args=None):
radio.load_mmap(options.mmap)
radio.sync_out()
print("Upload successful")
sys.exit(0)
except Exception as e:
LOG.exception(e)
sys.exit(1)
sys.exit(1)

if options.mmap and isinstance(radio, chirp_common.CloneModeRadio):
radio.save_mmap(options.mmap)
Loading