Merge lp://staging/~tribaal/landscape-client/1434546-wrong-exit-code-on-error into lp://staging/~landscape/landscape-client/trunk

Proposed by Chris Glass
Status: Rejected
Rejected by: Chris Glass
Proposed branch: lp://staging/~tribaal/landscape-client/1434546-wrong-exit-code-on-error
Merge into: lp://staging/~landscape/landscape-client/trunk
Diff against target: 118 lines (+33/-8)
2 files modified
landscape/configuration.py (+10/-2)
landscape/tests/test_configuration.py (+23/-6)
To merge this branch: bzr merge lp://staging/~tribaal/landscape-client/1434546-wrong-exit-code-on-error
Reviewer Review Type Date Requested Status
Benji York (community) Approve
Free Ekanayaka (community) Approve
Review via email: mp+253675@code.staging.launchpad.net

Description of the change

This branch fixes the linked bug, restoring the previous program behavior:
exit(2)'ing on registration error.

This made robot tests fail, on top of being a generally unsound UNIX practice.

To post a comment you must log in.
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

+1 with minor comments

review: Approve
Revision history for this message
Benji York (benji) wrote :

This branch is fine as-is. I did have a thought about how it could be better:

Looking at the new report_registration_outcome(), it seems to me that it is now two functions interleaved together. There is (almost) no shared code between reporting the outcome to the user and ending the program with an appropriate exit code. Perhaps a new function would be better, something like:

def determine_exit_code(what_happened):
    if what_happened == 'success':
        return 2
    else:
        return 0

Then the line "sys.exit(dermine_exit_code(what_happened))" can be added just after the call to report_registration_outcome().

This benefits the code by making the tests more straight forward (no changes are needed to existing tests, allowing them to remain focused on only one thing, the new tests will be similarly focused). Additionally, the code will be easier to understand (the question "what determines the exit code" can be answered by reading less code than previously).

What do you think?

review: Approve
Revision history for this message
Chris Glass (tribaal) wrote :

So, I think your approach is more elegant, so I rewrote this branch here: https://code.launchpad.net/~tribaal/landscape-client/take-two-1434546-exit-code-2-on-error

I'll close this merge proposal and resubmit the new one.

Unmerged revisions

815. By Chris Glass

Restore the previous behvior - exit(2) on registration errors.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: