Skip to content

Commit

Permalink
FAILED -> ERROR
Browse files Browse the repository at this point in the history
  • Loading branch information
sezanzeb committed Dec 27, 2024
1 parent d61e730 commit 0a5700c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions inputremapper/gui/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ def start_injecting(self):
self.message_broker.unsubscribe(self.show_injector_result)
self.show_status(
CTX_APPLY,
_("Failed to apply preset %s") % self.data_manager.active_preset.name,
_('Failed to apply preset "%s"') % self.data_manager.active_preset.name,
)

def show_injector_result(self, msg: InjectorStateMessage):
Expand All @@ -667,7 +667,7 @@ def show_injector_result(self, msg: InjectorStateMessage):
state = msg.state

def running():
msg = _("Applied preset %s") % self.data_manager.active_preset.name
msg = _('Applied preset "%s"') % self.data_manager.active_preset.name
if self.data_manager.active_preset.dangerously_mapped_btn_left():
msg += _(", CTRL + DEL to stop")
self.show_status(CTX_APPLY, msg)
Expand Down Expand Up @@ -697,10 +697,10 @@ def no_grab():
assert self.data_manager.active_preset # make mypy happy
state_calls: Dict[InjectorState, Callable] = {
InjectorState.RUNNING: running,
InjectorState.FAILED: partial(
InjectorState.ERROR: partial(
self.show_status,
CTX_ERROR,
_('Failed to apply preset "%s"') % self.data_manager.active_preset.name,
_('Error applying preset "%s"') % self.data_manager.active_preset.name,
),
InjectorState.NO_GRAB: no_grab,
InjectorState.UPGRADE_EVDEV: partial(
Expand Down
2 changes: 1 addition & 1 deletion inputremapper/gui/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def start_injecting(self) -> bool:
self.do_when_injector_state(
{
InjectorState.RUNNING,
InjectorState.FAILED,
InjectorState.ERROR,
InjectorState.NO_GRAB,
InjectorState.UPGRADE_EVDEV,
},
Expand Down
4 changes: 2 additions & 2 deletions inputremapper/injection/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class InjectorCommand(str, enum.Enum):
class InjectorState(str, enum.Enum):
UNKNOWN = "UNKNOWN"
STARTING = "STARTING"
FAILED = "FAILED"
ERROR = "FAILED"
RUNNING = "RUNNING"
STOPPED = "STOPPED"
NO_GRAB = "NO_GRAB"
Expand Down Expand Up @@ -174,7 +174,7 @@ def get_state(self) -> InjectorState:
if state in (InjectorState.STARTING, InjectorState.RUNNING) and not alive:
# we thought it is running (maybe it was when get_state was previously),
# but the process is not alive. It probably crashed
state = InjectorState.FAILED
state = InjectorState.ERROR
logger.error("Injector was unexpectedly found stopped")

logger.debug(
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from inputremapper.gui.reader_client import ReaderClient
from inputremapper.gui.utils import CTX_ERROR, CTX_APPLY, gtk_iteration
from inputremapper.gui.gettext import _
from inputremapper.injection.global_uinputs import GlobalUInputs, UInput, FrontendUInput
from inputremapper.injection.global_uinputs import GlobalUInputs, FrontendUInput
from inputremapper.configs.mapping import UIMapping, MappingData, Mapping
from tests.lib.spy import spy
from tests.lib.patches import FakeDaemonProxy
Expand Down Expand Up @@ -1048,17 +1048,17 @@ def f(data):

self.controller.start_injecting()
gtk_iteration(50)
self.assertEqual(calls[-1].msg, _("Applied preset %s") % "preset2")
self.assertEqual(calls[-1].msg, _('Applied preset "%s"') % "preset2")

mock.return_value = InjectorState.FAILED
mock.return_value = InjectorState.ERROR
self.controller.start_injecting()
gtk_iteration(50)
self.assertEqual(calls[-1].msg, _("Failed to apply preset %s") % "preset2")
self.assertEqual(calls[-1].msg, _('Error applying preset "%s"') % "preset2")

mock.return_value = InjectorState.NO_GRAB
self.controller.start_injecting()
gtk_iteration(50)
self.assertEqual(calls[-1].msg, "The device was not grabbed")
self.assertEqual(calls[-1].msg, _('Failed to apply preset "%s"') % "preset2")

mock.return_value = InjectorState.UPGRADE_EVDEV
self.controller.start_injecting()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def tearDown(self):
time.sleep(0.2)
self.assertIn(
self.injector.get_state(),
(InjectorState.STOPPED, InjectorState.FAILED, InjectorState.NO_GRAB),
(InjectorState.STOPPED, InjectorState.ERROR, InjectorState.NO_GRAB),
)
self.injector = None
evdev.InputDevice.grab = self.grab
Expand Down

0 comments on commit 0a5700c

Please sign in to comment.