Skip to content
Snippets Groups Projects
Commit b0b8cd89 authored by Jan David Mol's avatar Jan David Mol
Browse files

Merge branch 'L2SS-703-fix-statisticswriter-windows' into 'master'

Resolve L2SS-703 "Fix statisticswriter windows"

Closes L2SS-703

See merge request !282
parents 8b693412 f31acea0
No related branches found
No related tags found
1 merge request!282Resolve L2SS-703 "Fix statisticswriter windows"
...@@ -24,12 +24,12 @@ classifier = ...@@ -24,12 +24,12 @@ classifier =
[options] [options]
package_dir= package_dir=
=./ =.
packages=find: packages=find:
python_requires = >=3.7 python_requires = >=3.7
[options.packages.find] [options.packages.find]
where=./ where=.
[options.entry_points] [options.entry_points]
console_scripts = console_scripts =
......
...@@ -235,9 +235,8 @@ class XSTCollector(StatisticsCollector): ...@@ -235,9 +235,8 @@ class XSTCollector(StatisticsCollector):
# log if we're replacing a subband we were once recording # log if we're replacing a subband we were once recording
previous_subband_in_slot = self.parameters["xst_subbands"][subband_slot] previous_subband_in_slot = self.parameters["xst_subbands"][subband_slot]
if previous_subband_in_slot != fields.subband_index: if previous_subband_in_slot != fields.subband_index:
previous_subband_timestamp = datetime.datetime.fromtimestamp(self.parameters["xst_timestamps"][subband_slot]) if self.parameters["xst_timestamps"][subband_slot] > 0:
previous_subband_timestamp = datetime.datetime.fromtimestamp(self.parameters["xst_timestamps"][subband_slot])
if previous_subband_timestamp.timestamp() > 0:
logger.info(f"Stopped recording XSTs for subband {previous_subband_in_slot}. Last data for this subband was received at {previous_subband_timestamp}.") logger.info(f"Stopped recording XSTs for subband {previous_subband_in_slot}. Last data for this subband was received at {previous_subband_timestamp}.")
def xst_values(self, subband_indices = None): def xst_values(self, subband_indices = None):
......
...@@ -27,6 +27,12 @@ class receiver: ...@@ -27,6 +27,12 @@ class receiver:
# add payload to the header, and return the full packet # add payload to the header, and return the full packet
return header + payload return header + payload
def _read(self, length: int) -> bytes:
""" Low-level read function to fetch at most "length" (>1) bytes. Returns
nothing if there is no data left. """
return os.read(self.fd, length)
def read_data(self, data_length: int) -> bytes: def read_data(self, data_length: int) -> bytes:
""" Read exactly data_length bytes from the TCP connection. """ """ Read exactly data_length bytes from the TCP connection. """
...@@ -35,7 +41,7 @@ class receiver: ...@@ -35,7 +41,7 @@ class receiver:
# try to read the remainder. # try to read the remainder.
# NOTE: recv() may return less data than requested, and returns 0 # NOTE: recv() may return less data than requested, and returns 0
# if there is nothing left to read (end of stream) # if there is nothing left to read (end of stream)
more_data = os.read(self.fd, data_length - len(data)) more_data = self._read(data_length - len(data))
if not more_data: if not more_data:
# connection got dropped # connection got dropped
raise EOFError("End of stream") raise EOFError("End of stream")
...@@ -54,6 +60,10 @@ class tcp_receiver(receiver): ...@@ -54,6 +60,10 @@ class tcp_receiver(receiver):
super().__init__(fd=self.sock.fileno()) super().__init__(fd=self.sock.fileno())
def _read(self, length):
# On Windows, we cannot use os.read to read from sockets
return self.sock.recv(length)
def reconnect(self): def reconnect(self):
self.fd = None self.fd = None
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment