This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2418 from pypeclub/feature/OP-1172_Start-timer-po…
…st-launch-hook TimersManager: Start timer post launch hook
- Loading branch information
Showing
7 changed files
with
213 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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 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 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
3 changes: 3 additions & 0 deletions
3
openpype/modules/default_modules/timers_manager/exceptions.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class InvalidContextError(ValueError): | ||
"""Context for which the timer should be started is invalid.""" | ||
pass |
45 changes: 45 additions & 0 deletions
45
openpype/modules/default_modules/timers_manager/launch_hooks/post_start_timer.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from openpype.lib import PostLaunchHook | ||
|
||
|
||
class PostStartTimerHook(PostLaunchHook): | ||
"""Start timer with TimersManager module. | ||
This module requires enabled TimerManager module. | ||
""" | ||
order = None | ||
|
||
def execute(self): | ||
project_name = self.data.get("project_name") | ||
asset_name = self.data.get("asset_name") | ||
task_name = self.data.get("task_name") | ||
|
||
missing_context_keys = set() | ||
if not project_name: | ||
missing_context_keys.add("project_name") | ||
if not asset_name: | ||
missing_context_keys.add("asset_name") | ||
if not task_name: | ||
missing_context_keys.add("task_name") | ||
|
||
if missing_context_keys: | ||
missing_keys_str = ", ".join([ | ||
"\"{}\"".format(key) for key in missing_context_keys | ||
]) | ||
self.log.debug("Hook {} skipped. Missing data keys: {}".format( | ||
self.__class__.__name__, missing_keys_str | ||
)) | ||
return | ||
|
||
timers_manager = self.modules_manager.modules_by_name.get( | ||
"timers_manager" | ||
) | ||
if not timers_manager or not timers_manager.enabled: | ||
self.log.info(( | ||
"Skipping starting timer because" | ||
" TimersManager is not available." | ||
)) | ||
return | ||
|
||
timers_manager.start_timer_with_webserver( | ||
project_name, asset_name, task_name, logger=self.log | ||
) |
This file contains 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
Oops, something went wrong.