Retrieve robot_mode via python

Dear developers,
I would like to know how to get the Robot Mode via Python and turn the program into an URCap.
I assume that Primary_Client would allow me this but how can I add the script commands into the python code?
|Robot Modes
| — | — | — | — | — | — | — |
|Mode|Description|
|-1|ROBOT_MODE_NO_CONTROLLER|
|0|ROBOT_MODE_DISCONNECTED|
|1|ROBOT_MODE_CONFIRM_SAFETY|
|2|ROBOT_MODE_BOOTING|
|3|ROBOT_MODE_POWER_OFF|
|4|ROBOT_MODE_POWER_ON|
|5|ROBOT_MODE_IDLE|
|6|ROBOT_MODE_BACKDRIVE|
|7|ROBOT_MODE_RUNNING|
|8 ROBOT_MODE_UPDATING_FIRMWARE|

kindly.
Beck