Skip to content

Commit

Permalink
fix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
polybassa committed May 3, 2024
1 parent 9e1cc08 commit 2bdd00f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion scapy/contrib/automotive/ecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from types import GeneratorType
from threading import Lock

from scapy.compat import orb
from scapy.compat import orb, Self
from scapy.packet import Raw, Packet
from scapy.plist import PacketList
from scapy.sessions import DefaultSession
Expand Down Expand Up @@ -254,6 +254,10 @@ def get_modified_ecu_state(response, request, state, modify_in_place=False): #
layer.modify_ecu_state.im_func(response, request, new_state)
return new_state

def __reduce__(self):
# type: () -> Tuple[Type[Self], Tuple[str], Tuple[Dict[str, Any]]]
return self.__class__, ("EcuState",), (self.__dict__,)


class Ecu(object):
"""An Ecu object can be used to
Expand Down
2 changes: 1 addition & 1 deletion scapy/contrib/automotive/scanner/enumerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def pre_execute(self, socket, state, global_configuration):
self._tester_present_sender = None

def post_execute(self, socket, state, global_configuration):
# type: (_SocketUnion, EcuState, AutomotiveTestCaseExecutorConfiguration) -> None
# type: (_SocketUnion, EcuState, AutomotiveTestCaseExecutorConfiguration) -> None # noqa: E501
self._tester_present_sender = None

def execute(self, socket, state, **kwargs):
Expand Down
10 changes: 7 additions & 3 deletions scapy/contrib/automotive/uds_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ def get_new_edge(self,
state, new_state = edge
# Force TesterPresent if session is changed
new_state.tp = 1 # type: ignore
if close_socket and new_state.session == 2:
new_state.tp = 0
try:
if close_socket and new_state.session == 2: # type: ignore
new_state.tp = 0 # type: ignore
except (AttributeError, KeyError):
pass
return state, new_state
return None

Expand Down Expand Up @@ -217,7 +220,8 @@ def enter_state_with_tp(sock, # type: _SocketUnion
if not hasattr(sock, "ip"):
log_automotive.warning("Likely closing a CAN based socket! "
"This might be a configuration issue.")
log_automotive.info("Entered Programming Session: Closing socket connection")
log_automotive.info(
"Entered Programming Session: Closing socket connection")
sock.close()
conf.stop_event.wait(delay)

Expand Down

0 comments on commit 2bdd00f

Please sign in to comment.