tools.diagnostic
- class tools.diagnostic.Diagnostic
- classmethod config_points()
Returns a list of ConfigPoints describing this script’s configuration options. By default this function returns an empty list. Override it if you’d like configuration points.
- classmethod display_name() str
Returns the string used to identify this script in the Menu. Defaults to the class name. Override it if you would like to use a different name:
@classmethod def display_name(cls): return "Hello World"
Note that the screen is only 16 characters wide. Anything longer will be cut off.
- last_saved()
Return the ticks in milliseconds since last save.
- load_state_bytes() bytes
Check disk for saved state, if it exists, return the raw state value as bytes.
Check for a previously saved state. If it exists, return state as a byte string. If no state is found, an empty string will be returned.
- load_state_json() dict
Load previously saved state as a dict.
Check for a previously saved state. If it exists, return state as a dict. If no state is found, an empty dictionary will be returned.
- main()
Override this method with your script’s main loop method.
- remove_state()
Remove the state file for this script.
- save_state()
Encode state and call the appropriate persistence save method.
Override this class with the script specific encoding of state into the persistence format that best matches its use case. Then call the appropriate save method, such as save_state_json(state). See the class documentation for a full example.
- save_state_bytes(state: bytes)
Take state in persistence format as bytes and write to disk.
Note
Be mindful of how often save_state_bytes() is called because writing to disk too often can slow down the performance of your script. Only call save state when state has changed and consider adding a time since last save check to reduce save frequency.
- save_state_json(state: dict)
Take state as a dict and save as a json string.
Note
Be mindful of how often save_state_json() is called because writing to disk too often can slow down the performance of your script. Only call save state when state has changed and consider adding a time since last save check to reduce save frequency.