Skip to content
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

Merged
merged 1 commit into from
May 2, 2017

Conversation

mikepurvis
Copy link
Member

Looks like this:

$ catkin build
----------------------------------------------------------------
Profile:                     default
Extending:          [cached] /Users/mikepurvis/config_ws/install
Workspace:                   /Users/mikepurvis/config_ws
----------------------------------------------------------------
Source Space:       [exists] /Users/mikepurvis/config_ws/src
Log Space:          [exists] /Users/mikepurvis/config_ws/logs
Build Space:        [exists] /Users/mikepurvis/config_ws/build
Devel Space:        [exists] /Users/mikepurvis/config_ws/devel
Install Space:      [exists] /Users/mikepurvis/config_ws/install
DESTDIR:            [unused] None
----------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        merged
----------------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
----------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
----------------------------------------------------------------
Workspace configuration appears valid.
----------------------------------------------------------------
[build] Found '6' packages in 0.0 seconds.                                                                                
[build] Error: Cannot find required tool `make` on the PATH, is it installed?

Fixes #437.

wide_log(clr("[build] - `{}`".format(bt_name)))

except CommandMissing as e:
sys.exit(clr("[build] @!@{rf}Error:@| {0}").format(e))
Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

@mikepurvis mikepurvis Apr 28, 2017

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Member Author

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.

Copy link
Member Author

@mikepurvis mikepurvis May 1, 2017

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.)

@mikepurvis mikepurvis force-pushed the better-missing-command-msg branch from 240bf73 to 7d687ab Compare April 28, 2017 21:10
Copy link
Member

@wjwwood wjwwood left a 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.


def require_command(name, which):
if not which:
import errno
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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))
Copy link
Member

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?

@mikepurvis mikepurvis force-pushed the better-missing-command-msg branch from 7d687ab to 4286b08 Compare April 28, 2017 21:25
@mikepurvis mikepurvis force-pushed the better-missing-command-msg branch from 4286b08 to 846ee01 Compare April 29, 2017 11:30
@mikepurvis
Copy link
Member Author

Okay, I think this is good now.

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants