wakepy
wakepy copied to clipboard
Better error message when a method name has a typo or when method is not part of a Mode
Running
from wakepy import keep
with keep.running(methods=["org.freedesktop.ScreenSaver"]) as m:
print(m.used_method)
will cause an error:
Traceback (most recent call last):
File "/home/niko/code/wakepy/src/wakepy/some_test.py", line 3, in <module>
with keep.running(methods=["org.freedesktop.ScreenSaver"]) as m:
File "/home/niko/code/wakepy/src/wakepy/modes/keep.py", line 80, in running
return Mode.from_name(
File "/home/niko/code/wakepy/src/wakepy/core/mode.py", line 252, in from_name
selected_methods = select_methods(methods_for_mode, use_only=methods, omit=omit)
File "/home/niko/code/wakepy/src/wakepy/core/mode.py", line 487, in select_methods
raise ValueError(
ValueError: Methods ['org.freedesktop.ScreenSaver'] in `use_only` are not part of `methods`!
using wakepy 0.8.0dev 8b1b565. The error message could say that the selected method does not support the select mode or has a typo.