1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-14 16:07:18 +00:00

Update FSM documentation

This commit is contained in:
Kristóf Tóth 2018-07-11 10:17:19 +02:00
parent 7949d94493
commit 185f1165cf

View File

@ -209,7 +209,7 @@ There are two ways to define a state machine:
- Using a YAML configuration file - Using a YAML configuration file
- Implementing it in Python by hand - Implementing it in Python by hand
The first option enables you to handle FSM callbacks and custom logic in any programming language (not just Python) and is generally really easy to work with. The first option allows you to handle FSM callbacks and custom logic in any programming language (not just Python) and is generally really easy to work with (you can execute arbitrary shell commands on events).
You should choose this method unless you have good reason not to. You should choose this method unless you have good reason not to.
This involves creating your YAML file (see `test_fsm.yml` for an example) and parsing it using our `YamlFSM` class (see `event_handler_main.py` for an example). This involves creating your YAML file (see `test_fsm.yml` for an example) and parsing it using our `YamlFSM` class (see `event_handler_main.py` for an example).
@ -224,6 +224,12 @@ Transition callbacks:
- `before` - `before`
- `after` - `after`
In your YAML file you can use these in the state and transition objects as keys, then add a shell command to run as a value (again, see `test_fsm.yml` for examples).
It is also possible to add preconditions to transitions.
This is done by adding a `predicates` key with a list of shell commands to run.
If you do this, the transition will only succeed if the return code of all predicates was `0` (as per unix convention for success).
## Baby steps ## Baby steps
When creating your own challenge the process should be the following: When creating your own challenge the process should be the following: