-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better message when missing a required command line tool. #455
Conversation
wide_log(clr("[build] - `{}`".format(bt_name))) | ||
|
||
except CommandMissing as e: | ||
sys.exit(clr("[build] @!@{rf}Error:@| {0}").format(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intent here would be to use a tuple ultimately to catch other kinds of exceptions that may be necessary to throw for problems discovered during job creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok, but what do you think about putting this try catch around all of the the build_isolated_workspace
function? Indenting this much code is just making it harder to read imo, and I think it should be ok to include the rest of the function in this try-catch right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean moving it to catkin_build/cli.py
? That can be done. It'll mean importing the exception there instead of here, which probably doesn't really matter.
The main thing is not catching everything— we still want stack traces for unknown problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that also sounds fine, though I was talking about just making a new function here that calls the current function in a try-catch, but your suggestion makes more sense.
In the end it's a small thing, but among other things it makes this diff hard to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if git/github's diff were smarter about recognizing blocks that have changed only in indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether there is any UI for this, but you can get the diff renderer to ignore whitespace changes by appending w=1
to the url: https://github.com/catkin/catkin_tools/pull/455/files?w=1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nice! TIL.
|
||
def __init__(self, name): | ||
super(CommandMissing, self).__init__( | ||
'Cannot find required tool `%s` on the PATH, is it installed?' % name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to move this to its own exceptions.py
file, didn't want to bother with that unless there was a clear need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(A good motivation to do so might be eliminating the use of sys.exit
within build_isolated_workspace
, in favour of throwing other exceptions that resolve to the string error messages. Doing this would make the function more cooperative as far as being wrapped or called from other tools.)
240bf73
to
7d687ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a few comments, but otherwise lgtm.
catkin_tools/jobs/utils.py
Outdated
|
||
def require_command(name, which): | ||
if not which: | ||
import errno |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need errno
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh fail, that's a leftover— an earlier version of this threw OSError instead. Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is simple enough now that it could probably just be inlined; I don't really care one way or another about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine as-is for me.
wide_log(clr("[build] - `{}`".format(bt_name))) | ||
|
||
except CommandMissing as e: | ||
sys.exit(clr("[build] @!@{rf}Error:@| {0}").format(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok, but what do you think about putting this try catch around all of the the build_isolated_workspace
function? Indenting this much code is just making it harder to read imo, and I think it should be ok to include the rest of the function in this try-catch right?
7d687ab
to
4286b08
Compare
4286b08
to
846ee01
Compare
Okay, I think this is good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Looks like this:
Fixes #437.