-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Plugin hook update #3101
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
Open
bjeffries
wants to merge
11
commits into
mitre:master
Choose a base branch
from
bjeffries:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Plugin hook update #3101
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d1140f9
generalized hook in planning_svc and added missing check in op_api_ma…
76b17e7
was using old operation_api_manager.py, now leveraging latest
a06c97e
fixed encoded command ref
43f01ed
Merge branch 'master' into master
mkultraWasHere 0afaf2a
Merge branch 'master' into master
mkultraWasHere 9654088
Added inline comment to hook purpose and fixed style issue with unuse…
bjeffries 858164c
pulling out function
mkultraWasHere 4bca515
flake 8
mkultraWasHere 755f8f0
missing await
mkultraWasHere 6e0cd12
Merge branch 'master' into master
deacon-mp f4be15b
Merge branch 'master' into master
deacon-mp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -351,9 +351,7 @@ async def _generate_new_links(self, operation, agent, abilities, link_status): | |||||||||||
| executor = await agent.get_preferred_executor(ability) | ||||||||||||
| if not executor: | ||||||||||||
| continue | ||||||||||||
|
|
||||||||||||
| if executor.HOOKS and executor.language and executor.language in executor.HOOKS: | ||||||||||||
| await executor.HOOKS[executor.language](ability, executor) | ||||||||||||
| self._call_ability_plugin_hooks(ability, executor) | ||||||||||||
| if executor.command: | ||||||||||||
| link = Link.load(dict(command=self.encode_string(executor.test), paw=agent.paw, score=0, | ||||||||||||
| ability=ability, executor=executor, status=link_status, | ||||||||||||
|
|
@@ -391,6 +389,11 @@ async def _generate_cleanup_links(self, operation, agent, link_status): | |||||||||||
| lnk.apply_id(agent.host) | ||||||||||||
| links.append(lnk) | ||||||||||||
| return links | ||||||||||||
|
|
||||||||||||
| async def _call_ability_plugin_hooks(self, ability, executor): | ||||||||||||
| """Calls any plugin hooks (at runtime) that exist for the ability and executor.""" | ||||||||||||
| for _hook, fcall in executor.HOOKS.items(): | ||||||||||||
| await fcall(ability, executor) | ||||||||||||
|
||||||||||||
| for _hook, fcall in executor.HOOKS.items(): | |
| await fcall(ability, executor) | |
| if executor.HOOKS: | |
| for _hook, fcall in executor.HOOKS.items(): | |
| await fcall(ability, executor) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 code will fail with an AttributeError if
executor.HOOKSis None or undefined. Add a null check before iterating:if executor.HOOKS:before the for loop.