Skip to content

Commit 600ac4a

Browse files
committed
fix: client banner to obtain SI version from SmartInspect
1 parent 6a4738a commit 600ac4a

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

protocols/tcp_protocol.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212

1313

1414
class TcpProtocol(Protocol):
15-
__BUFFER_SIZE = 0x2000
16-
__CLIENT_BANNER = bytearray(f"SmartInspect Python Library v\n", encoding="UTF-8")
17-
# __CLIENT_BANNER = bytearray(f"SmartInspect Python Library v{SmartInspect.get_version()}\n", encoding="UTF-8")
18-
__ANSWER_BUFFER_SIZE = 0x2000
19-
_hostname = "127.0.0.1"
20-
_timeout = 30000
21-
_port = 4228
15+
__BUFFER_SIZE: int = 0x2000
16+
__CLIENT_BANNER_TEMPLATE: str = "SmartInspect Python Library v{}\n"
17+
__ANSWER_BUFFER_SIZE: int = 0x2000
18+
_hostname: str = "127.0.0.1"
19+
_timeout: int = 30000
20+
_port: int = 4228
2221

2322
def __init__(self):
2423
super().__init__()
@@ -59,7 +58,9 @@ def _read_server_banner(self) -> None:
5958
"Connection has been closed unexpectedly")
6059

6160
def _send_client_banner(self) -> None:
62-
self.__stream.write(self.__CLIENT_BANNER)
61+
from smartinspect import SmartInspect
62+
si_version = SmartInspect.get_version()
63+
self.__stream.write(self.__CLIENT_BANNER_TEMPLATE.format(si_version).encode("UTF-8"))
6364
self.__stream.flush()
6465

6566
def _internal_connect(self):

smartinspect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def set_resolution(self, resolution: ClockResolution) -> None:
6868
if isinstance(resolution, ClockResolution):
6969
self.__resolution = resolution
7070

71-
@property
72-
def version(self) -> str:
73-
return self.__VERSION
71+
@classmethod
72+
def get_version(cls) -> str:
73+
return cls.__VERSION
7474

7575
@property
7676
def hostname(self) -> str:

0 commit comments

Comments
 (0)