Skip to content

Commit

Permalink
Merge branch 'master' into minor-import-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dkfellows committed Nov 8, 2018
2 parents 8b1aaf3 + f43fc6e commit 70de4a8
Show file tree
Hide file tree
Showing 64 changed files with 310 additions and 287 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ before_install:
install:
- python ./setup.py install
- pip install -r requirements-test.txt
- pip install python-coveralls
- pip install python-coveralls 'coverage>=4.4'
- pip install spinnaker_proxy

script:
Expand Down
26 changes: 6 additions & 20 deletions board_test_configuration.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import socket
import os
import platform
import subprocess
import socket
import unittest
import time
from six.moves import configparser
from spinn_utilities.ping import Ping
from spinnman.model import BMPConnectionData

_LOCALHOST = "127.0.0.1"
Expand All @@ -15,6 +13,7 @@


class BoardTestConfiguration(object):

def __init__(self):
self.localhost = None
self.localport = None
Expand All @@ -35,7 +34,7 @@ def set_up_local_virtual_board(self):

def set_up_remote_board(self):
self.remotehost = self._config.get("Machine", "machineName")
if not self.host_is_reachable(self.remotehost):
if not Ping.host_is_reachable(self.remotehost):
raise unittest.SkipTest("test board appears to be down")
self.board_version = self._config.getint("Machine", "version")
self.bmp_names = self._config.get("Machine", "bmp_names")
Expand All @@ -46,10 +45,10 @@ def set_up_remote_board(self):
0, 0, self.bmp_names, [0], None)]
self.auto_detect_bmp = \
self._config.getboolean("Machine", "auto_detect_bmp")
self.localport = 54321
self.localport = _PORT
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect((self.remotehost, 0))
s.connect((self.remotehost, _PORT))
self.localhost = s.getsockname()[0]
finally:
s.close()
Expand All @@ -59,16 +58,3 @@ def set_up_nonexistent_board(self):
self.localport = _PORT
self.remotehost = _NOHOST
self.board_version = self._config.getint("Machine", "version")

@staticmethod
def host_is_reachable(ipaddr):
if platform.platform().lower().startswith("windows"):
cmd = "ping -n 1 -w 1 "
else:
cmd = "ping -c 1 -W 1 "
process = subprocess.Popen(
cmd + ipaddr, shell=True, stdout=subprocess.PIPE)
time.sleep(1.2)
process.stdout.close()
process.wait()
return process.returncode == 0
2 changes: 1 addition & 1 deletion spinnman/connections/abstract_classes/scp_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_scp_data(self, scp_request):
def send_scp_request(self, scp_request):
""" Sends an SCP request down this connection
Messages must have the following properties:
Messages must have the following properties:
* source_port is None or 7
* source_cpu is None or 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@add_metaclass(AbstractBase)
class SpinnakerBootReceiver(Connection):
""" A receiver of Spinnaker boot messages
""" A receiver of SpiNNaker boot messages
"""

__slots__ = ()
Expand Down
4 changes: 2 additions & 2 deletions spinnman/connections/udp_packet_connections/bmp_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ def __init__(self, connection_data):

@property
def cabinet(self):
""" The cabinet id of the BMP
""" The cabinet ID of the BMP
:rtype: int
"""
return self._cabinet

@property
def frame(self):
""" The frame id of the BMP
""" The frame ID of the BMP
:rtype: int
"""
Expand Down
18 changes: 12 additions & 6 deletions spinnman/connections/udp_packet_connections/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def update_sdp_header_for_udp_send(sdp_header, source_x, source_y):


def get_socket():
"""Wrapper round socket() system call"""
""" Wrapper round socket() system call.
"""
try:
# Create a UDP Socket
return socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand All @@ -37,7 +38,8 @@ def get_socket():


def set_receive_buffer_size(sock, size):
"""Wrapper round setsockopt() system call"""
""" Wrapper round setsockopt() system call.
"""
try:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, size)
except Exception:
Expand All @@ -48,7 +50,8 @@ def set_receive_buffer_size(sock, size):


def bind_socket(sock, host, port):
"""Wrapper round bind() system call"""
""" Wrapper round bind() system call.
"""
try:
# Bind the socket
sock.bind((str(host), int(port)))
Expand All @@ -59,7 +62,8 @@ def bind_socket(sock, host, port):


def resolve_host(host):
"""Wrapper round gethostbyname() system call"""
""" Wrapper round gethostbyname() system call.
"""
try:
return socket.gethostbyname(host)
except Exception as exception:
Expand All @@ -69,7 +73,8 @@ def resolve_host(host):


def connect_socket(sock, remote_address, remote_port):
"""Wrapper round connect() system call"""
""" Wrapper round connect() system call.
"""
try:
sock.connect((str(remote_address), int(remote_port)))
except Exception as exception:
Expand All @@ -79,7 +84,8 @@ def connect_socket(sock, remote_address, remote_port):


def get_socket_address(sock):
"""Wrapper round getsockname() system call"""
""" Wrapper round getsockname() system call.
"""
try:
addr, port = sock.getsockname()
# Ensure that a standard address is used for the INADDR_ANY
Expand Down
6 changes: 3 additions & 3 deletions spinnman/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# the address of the start of the VCPU structure (copied from sark.h)
CPU_INFO_OFFSET = 0xe5007000

# how many bytes the cpu info data takes up
# how many bytes the CPU info data takes up
CPU_INFO_BYTES = 128

# the address at which user0 register starts
Expand Down Expand Up @@ -96,7 +96,7 @@
# number of chips to check are booted fully from the middle
NO_MIDDLE_CHIPS_TO_CHECK = 8

# a listing of what spinnaker specific EIEIO commands there are.
# a listing of what SpiNNaker specific EIEIO commands there are.
EIEIO_COMMAND_IDS = Enum(
value="EIEIO_COMMAND_IDS",
names=[
Expand Down Expand Up @@ -141,7 +141,7 @@
]
)

# the values used by the SCP iptag time outs. These control how long to wait
# the values used by the SCP IP tag time outs. These control how long to wait
# for any message request which requires a response, before raising an error.
# The value is calculated via the following formulae
# 10ms * 2^(tag_timeout_value - 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ class DatabaseConfirmation(EIEIOCommandMessage):
def __init__(self, database_path=None):
super(DatabaseConfirmation, self).__init__(EIEIOCommandHeader(
EIEIO_COMMAND_IDS.DATABASE_CONFIRMATION))
self._database_path = database_path
self._database_path = None
if database_path is not None:
self._database_path = database_path.encode()

@property
def database_path(self):
return self._database_path
if self._database_path is not None:
return self._database_path.decode()
else:
return None

@property
def bytestring(self):
Expand Down
2 changes: 1 addition & 1 deletion spinnman/messages/eieio/command_messages/host_data_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def region_id(self, ack_id):
if len(self._region_id) > ack_id:
return self._region_id[ack_id]
raise SpinnmanInvalidParameterTypeException(
"request_id", "integer", "region id ack_id needs to be"
"request_id", "integer", "region ID ack_id needs to be"
"comprised between 0 and {0:d}; current value: {1:d}".format(
len(self._region_id) - 1, ack_id))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def region_id(self, request_id):
if len(self._region_id) > request_id:
return self._region_id[request_id]
raise SpinnmanInvalidParameterTypeException(
"request_id", "integer", "region id request needs to be"
"request_id", "integer", "region ID request needs to be"
"comprised between 0 and {0:d}; current value: {1:d}".format(
len(self._region_id) - 1, request_id))

Expand Down
6 changes: 3 additions & 3 deletions spinnman/messages/eieio/create_eieio_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def read_eieio_command_message(data, offset):
# End of all buffers, stop execution
elif command_number == EIEIO_COMMAND_IDS.EVENT_STOP.value:
return EventStopRequest()
# Stop complaining that there is sdram free space for buffers
# Stop complaining that there is SDRAM free space for buffers
elif command_number == EIEIO_COMMAND_IDS.STOP_SENDING_REQUESTS.value:
return StopRequests()
# Start complaining that there is sdram free space for buffers
# Start complaining that there is SDRAM free space for buffers
elif command_number == EIEIO_COMMAND_IDS.START_SENDING_REQUESTS.value:
return StartRequests()
# Spinnaker requesting new buffers for spike source population
# SpiNNaker requesting new buffers for spike source population
elif command_number == EIEIO_COMMAND_IDS.SPINNAKER_REQUEST_BUFFERS.value:
return SpinnakerRequestBuffers.from_bytestring(
command_header, data, offset + 2)
Expand Down
2 changes: 1 addition & 1 deletion spinnman/messages/scp/enums/iptag_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class IPTagCommand(Enum):
""" SCP IPTag Commands
""" SCP IP tag Commands
"""
NEW = 0
SET = 1
Expand Down
2 changes: 1 addition & 1 deletion spinnman/messages/scp/impl/app_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppStop(AbstractSCPRequest):

def __init__(self, app_id):
"""
:param app_id: The id of the application, between 0 and 255
:param app_id: The ID of the application, between 0 and 255
:type app_id: int
"""
super(AppStop, self).__init__(
Expand Down
2 changes: 1 addition & 1 deletion spinnman/messages/scp/impl/application_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ApplicationRun(AbstractSCPRequest):

def __init__(self, app_id, x, y, processors, wait=False):
"""
:param app_id: The id of the application to run, between 16 and 255
:param app_id: The ID of the application to run, between 16 and 255
:type app_id: int
:param x: The x-coordinate of the chip to run on, between 0 and 255
:type x: int
Expand Down
2 changes: 1 addition & 1 deletion spinnman/messages/scp/impl/count_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CountState(AbstractSCPRequest):
def __init__(self, app_id, state):
"""
:param app_id: The id of the application, between 0 and 255
:param app_id: The ID of the application, between 0 and 255
:type app_id: int
:param state: The state to count
:type state: :py:class:`spinnman.model.cpu_state.CPUState`
Expand Down
4 changes: 2 additions & 2 deletions spinnman/messages/scp/impl/fixed_route_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FixedRouteInit(AbstractSCPRequest):
__slots__ = []

def __init__(self, x, y, entry, app_id):
""" sets a fixed route entry
""" Sets a fixed route entry
:param x: The x-coordinate of the chip, between 0 and 255,\
this is not checked due to speed restrictions
Expand All @@ -19,7 +19,7 @@ def __init__(self, x, y, entry, app_id):
this is not checked due to speed restrictions
:type y: int
:param entry: the fixed route entry converted for writing
:param app_id: The id of the application with which to associate the\
:param app_id: The ID of the application with which to associate the\
routes. If not specified, defaults to 0.
:type app_id: int
:raise spinnman.exceptions.SpinnmanInvalidParameterException:\
Expand Down
4 changes: 2 additions & 2 deletions spinnman/messages/scp/impl/fixed_route_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class FixedRouteRead(AbstractSCPRequest):
__slots__ = []

def __init__(self, x, y, app_id):
""" sets a fixed route entry
""" Sets a fixed route entry
:param x: The x-coordinate of the chip, between 0 and 255,\
this is not checked due to speed restrictions
:type x: int
:param y: The y-coordinate of the chip, between 0 and 255\
this is not checked due to speed restrictions
:type y: int
:param app_id: The id of the application with which to associate the\
:param app_id: The ID of the application with which to associate the\
routes. If not specified, defaults to 0.
:type app_id: int
:raise spinnman.exceptions.SpinnmanInvalidParameterException:\
Expand Down
2 changes: 1 addition & 1 deletion spinnman/messages/scp/impl/flood_fill_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FloodFillData(AbstractSCPRequest):
def __init__(self, nearest_neighbour_id, block_no, base_address, data,
offset=0, length=None):
"""
:param nearest_neighbour_id: The id of the packet, between 0 and 127
:param nearest_neighbour_id: The ID of the packet, between 0 and 127
:type nearest_neighbour_id: int
:param block_no: Which block this block is, between 0 and 255
:type block_no: int
Expand Down
4 changes: 2 additions & 2 deletions spinnman/messages/scp/impl/flood_fill_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def __init__(
self, nearest_neighbour_id, app_id=0, processors=None, wait=False):
"""
:param nearest_neighbour_id: The id of the packet, between 0 and 127
:param nearest_neighbour_id: The ID of the packet, between 0 and 127
:type nearest_neighbour_id: int
:param app_id: The application id to start using the data, between 16\
:param app_id: The application ID to start using the data, between 16\
and 255. If not specified, no application is started
:type app_id: int
:param processors: A list of processors on which to start the\
Expand Down
4 changes: 2 additions & 2 deletions spinnman/messages/scp/impl/flood_fill_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class FloodFillStart(AbstractSCPRequest):

def __init__(self, nearest_neighbour_id, n_blocks, x=None, y=None):
"""
:param nearest_neighbour_id: The id of the packet, between 0 and 127
:param nearest_neighbour_id: The ID of the packet, between 0 and 127
:type nearest_neighbour_id: int
:param n_blocks: The number of blocks of data that will be sent,\
between 0 and 255
:type n_blocks: int
:param x: The x-coordindate of the chip to load the data on to. If not\
:param x: The x-coordinate of the chip to load the data on to. If not\
specified, the data will be loaded on to all chips
:type x: int
:param y: The y-coordinate of the chip to load the data on to. If not\
Expand Down
2 changes: 1 addition & 1 deletion spinnman/messages/scp/impl/get_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, x, y, p):
:type x: int
:param y: The y-coordinate of the chip to read from, between 0 and 255
:type y: int
:param p: The id of the processor to read the version from,\
:param p: The ID of the processor to read the version from,\
between 0 and 31
:type p: int
:raise spinnman.exceptions.SpinnmanInvalidParameterException:
Expand Down
6 changes: 3 additions & 3 deletions spinnman/messages/scp/impl/iptag_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def is_reverse(self):

@property
def strip_sdp(self):
""" True if the tag is to strip sdp
""" True if the tag is to strip the SDP header
:rtype: bool
"""
Expand Down Expand Up @@ -206,15 +206,15 @@ def spin_chip_y(self):

@property
def spin_port(self):
""" The spin-port of the ip tag
""" The spin-port of the IP tag
:rtype: int
"""
return self._spin_port

@property
def spin_cpu(self):
""" The cpu id of the ip tag
""" The CPU ID of the IP tag
:rtype: int
"""
Expand Down
2 changes: 1 addition & 1 deletion spinnman/messages/scp/impl/read_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, x, y, link, base_address, size, cpu=0):
:param cpu: The CPU core to use, normally 0 (or if a BMP, the board \
slot number)
:type cpu: int
:param link: The id of the link down which to send the query
:param link: The ID of the link down which to send the query
:type link: int
:param base_address: The positive base address to start the read from
:type base_address: int
Expand Down
Loading

0 comments on commit 70de4a8

Please sign in to comment.