File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed
usbguard_simple_gui_py_qt Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -139,9 +139,9 @@ def _on_device_presence_changed(
139139 def _on_device_policy_changed (
140140 self ,
141141 device : Device ,
142- _resolved_target_old : int ,
143- _resolved_target_new : int ,
144- _resolved_rule_id : int
142+ _target_old : RuleTarget ,
143+ _target_new : RuleTarget ,
144+ _rule_id : int
145145 ) -> None :
146146 self ._device_model .update_or_add_device (device )
147147
Original file line number Diff line number Diff line change @@ -55,12 +55,16 @@ class EventPresenceChangeType(IntEnum):
5555 REMOVE = 3
5656
5757
58+ _TARGET_TO_INT = {
59+ RuleTarget .ALLOW : 0 ,
60+ RuleTarget .BLOCK : 1 ,
61+ RuleTarget .REJECT : 2 ,
62+ }
63+
64+ _INT_TO_TARGET = {_TARGET_TO_INT [t ]: t for t in _TARGET_TO_INT }
65+
66+
5867class UsbguardDbusInterface :
59- _TARGET_TO_INT = {
60- RuleTarget .ALLOW : 0 ,
61- RuleTarget .BLOCK : 1 ,
62- RuleTarget .REJECT : 2 ,
63- }
6468
6569 def __init__ (self ) -> None :
6670 DBusGMainLoop (set_as_default = True )
@@ -117,7 +121,7 @@ def apply_device_policy(
117121 ) -> Optional [int ]:
118122 response : UInt32 = self ._devices .applyDevicePolicy (
119123 device_id ,
120- self . _TARGET_TO_INT [target ],
124+ _TARGET_TO_INT [target ],
121125 permanent )
122126 return int (response ) if permanent else None
123127
@@ -173,8 +177,8 @@ def _on_device_policy_changed(
173177 :param _attributes: A dictionary of device attributes and their values.
174178 """
175179 try :
176- resolved_target_old = int (target_old )
177- resolved_target_new = int (target_new )
180+ resolved_target_old = _INT_TO_TARGET [ int (target_old )]
181+ resolved_target_new = _INT_TO_TARGET [ int (target_new )]
178182 resolved_rule_id = int (rule_id )
179183 device = Device (
180184 device_id = int (device_id ),
You can’t perform that action at this time.
0 commit comments