-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bb1781
commit d235c22
Showing
5 changed files
with
131 additions
and
34 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
28 changes: 28 additions & 0 deletions
28
package/cloudshell/cp/vcenter/common/vcenter/cancellation_service.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,28 @@ | ||
class CancellationException(Exception): | ||
"""Raised when command was cancelled from the CloudShell""" | ||
|
||
def __init__(self, message, data): | ||
""" | ||
:param str message: | ||
:param dict data: | ||
:return: | ||
""" | ||
# Call the base class constructor with the parameters it needs | ||
super(CancellationException, self).__init__(message) | ||
|
||
self.data = data if data else {} | ||
|
||
|
||
class CommandCancellationService(object): | ||
def check_if_cancelled(self, cancellation_context, data=None): | ||
"""Check if command was cancelled from the CloudShell | ||
:param cancellation_context cloudshell.shell.core.driver_context.CancellationContext instance | ||
:param dict data: Dictionary that will be added to the cancellation exception if raised. | ||
Use this container to add context data to the cancellation exception to be used | ||
by the exception handler | ||
:raises cloudshell.cp.azure.common.exceptions.cancellation_exception.CancellationException | ||
:return: | ||
""" | ||
if cancellation_context and cancellation_context.is_cancelled: | ||
raise CancellationException("Command was cancelled", data) |
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