• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / SpiNNMan / 6574804013

19 Oct 2023 12:47PM UTC coverage: 51.937% (+1.2%) from 50.777%
6574804013

Pull #327

github

Christian-B
typing changes
Pull Request #327: Type Annotations and Checking

105 of 1288 branches covered (0.0%)

Branch coverage included in aggregate %.

2375 of 2375 new or added lines in 180 files covered. (100.0%)

4775 of 8108 relevant lines covered (58.89%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.0
/spinnman/messages/scp/abstract_messages/scp_response.py
1
# Copyright (c) 2014 The University of Manchester
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     https://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
from typing import Optional
1✔
15
from spinn_utilities.abstract_base import AbstractBase, abstractmethod
1✔
16
from spinnman.messages.sdp import SDPHeader
1✔
17
from spinnman.messages.scp import SCPResponseHeader
1✔
18

19
# The offset of the header from the start of a received packet
20
# (8 bytes of SDP header)
21
_SCP_HEADER_OFFSET = 8
1✔
22

23
# The offset of the data from the start of a received packet
24
# (8 bytes of SDP header + 4 bytes of SCP header)
25
_SCP_DATA_OFFSET = 12
1✔
26

27

28
class AbstractSCPResponse(object, metaclass=AbstractBase):
1✔
29
    """
30
    Represents an abstract SCP Response.
31
    """
32
    __slots__ = (
1✔
33
        "_scp_response_header",
34
        "_sdp_header")
35

36
    def __init__(self) -> None:
1✔
37
        self._sdp_header: Optional[SDPHeader] = None
1✔
38
        self._scp_response_header: Optional[SCPResponseHeader] = None
1✔
39

40
    def read_bytestring(self, data: bytes, offset: int):
1✔
41
        """
42
        Reads a packet from a byte-string of data.
43

44
        :param bytes data: The byte-string to be read
45
        :param int offset:
46
            The offset in the data from which the response should be read
47
        """
48
        self._sdp_header = SDPHeader.from_bytestring(data, offset)
1✔
49
        self._scp_response_header = SCPResponseHeader.from_bytestring(
1✔
50
            data, _SCP_HEADER_OFFSET + offset)
51
        self.read_data_bytestring(data, _SCP_DATA_OFFSET + offset)
1✔
52

53
    @abstractmethod
1✔
54
    def read_data_bytestring(self, data: bytes, offset: int):
1✔
55
        """
56
        Reads the remainder of the data following the header.
57

58
        :param bytes data: The byte-string to read from
59
        :param int offset: The offset into the data after the headers
60
        """
61
        raise NotImplementedError
62

63
    @property
1✔
64
    def sdp_header(self) -> SDPHeader:
1✔
65
        """
66
        The SDP header from the response.
67

68
        :rtype: SDPHeader
69
        """
70
        assert self._sdp_header is not None, "no response read"
×
71
        return self._sdp_header
×
72

73
    @property
1✔
74
    def scp_response_header(self) -> SCPResponseHeader:
1✔
75
        """
76
        The SCP header from the response.
77

78
        :rtype: SCPResponseHeader
79
        """
80
        assert self._scp_response_header is not None, "no response read"
1✔
81
        return self._scp_response_header
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc