-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/NTIA/scos-actions into ca…
…librate_to_antenna
- Loading branch information
Showing
4 changed files
with
66 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""A simple example action that raises a RuntimeError.""" | ||
|
||
import logging | ||
from typing import Optional | ||
|
||
from scos_actions.actions.interfaces.action import Action | ||
from scos_actions.hardware.sensor import Sensor | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class RuntimeErrorAction(Action): | ||
""" | ||
Raise a runtime error. | ||
This is useful for testing and debugging. Note: this action | ||
is currently not loaded in any scenario and must be manually | ||
added to use. | ||
""" | ||
|
||
def __init__(self): | ||
super().__init__(parameters={"name": "RuntimeErrorAction"}) | ||
|
||
def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): | ||
msg = "Raising RuntimeError {name}/{tid}" | ||
schedule_entry_name = schedule_entry["name"] | ||
logger.log(msg=msg.format(name=schedule_entry_name, tid=task_id)) | ||
raise RuntimeError("RuntimeError from RuntimeErrorAction") |
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 @@ | ||
"""A simple action that raises SystemExit""" | ||
|
||
import logging | ||
from typing import Optional | ||
|
||
from scos_actions.actions.interfaces.action import Action | ||
from scos_actions.hardware.sensor import Sensor | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class SystemExitAction(Action): | ||
""" | ||
Raise a SystemExit. | ||
This is useful for testing and debugging. Note: this action | ||
is currently not loaded in any scenario and must be manually | ||
added to use. | ||
""" | ||
|
||
def __init__(self): | ||
super().__init__(parameters={"name": "SystemExitAction"}) | ||
|
||
def __call__(self, sensor: Optional[Sensor], schedule_entry: dict, task_id: int): | ||
msg = "Raising SystemExit {name}/{tid}" | ||
schedule_entry_name = schedule_entry["name"] | ||
logger.log(msg=msg.format(name=schedule_entry_name, tid=task_id)) | ||
raise SystemExit("SystemExit produced by SystemExitAction. ") |
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