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

hook: switch to using check_call #3409

Merged
merged 3 commits into from
Oct 17, 2019
Merged

Conversation

jackwilsdon
Copy link
Member

A small change but hopefully part of a larger piece of work around #2835.

@jackwilsdon jackwilsdon changed the title Switch to using check_call for hooks hook: switch to using check_call Oct 16, 2019
@sampsyo
Copy link
Member

sampsyo commented Oct 16, 2019

Seems right to me! Maybe we should also catch CalledProcessError and print a friendly message when the hook fails?

@jackwilsdon
Copy link
Member Author

Aha, good catch! I clearly didn't look into the check_call documentation enough to see it can throw things other than an OSError 😬

Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

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

Nice; this looks perfect to me! Thanks for adding tests!

TBH, this might address 90% of the real-world utility of #2835. As you noted in that thread, it's not entirely clear how we'd actually go about implementing on_error as proposed. Actions like skip_album would only even make sense for a subset of events, and even then, the infrastructure is not set up yet to let events communicate such signals back to the import pipeline.

So I think it might be best to merge this (with a changelog entry!) now and leave any consideration of user-defined error handling for another day.

Thank you again for addressing this!

@jackwilsdon
Copy link
Member Author

jackwilsdon commented Oct 17, 2019

I've gotten half way through implementing support for on_error - I've implemented on_error: abort by raising a ui.UserError which does seem to quit beets, although I'm not too sure on what state it actually leaves beets in 😕 I may as well go ahead and finish it off a bit more (thinking of just implementing abort, log and ignore without any of the skip_* handlers) and I'll open a PR for it so we can discuss the merits of implementing it there.

I'll go ahead and update the changelog (I always seem to forget this step!).

sampsyo added a commit that referenced this pull request Oct 17, 2019
@sampsyo sampsyo merged commit c5dab18 into beetbox:master Oct 17, 2019
@sampsyo
Copy link
Member

sampsyo commented Oct 17, 2019

Perfect; thanks! I merged this as is.

That's cool; thanks for looking into on_error. And indeed, I'm actually also not entirely sure how dangerous just raising a UserError might be—it seems to depend a lot on the context, such as the particular event that is aborting things? Maybe we can get feedback from the original requester about what exactly they wanted to happen and why…

@jackwilsdon jackwilsdon deleted the hook-check-call branch October 17, 2019 18:03
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.

2 participants