-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from SpiNNakerManchester/pylint_strict
Pylint strict
- Loading branch information
Showing
11 changed files
with
205 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2023 The University of Manchester | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Our abbreviations/names | ||
|
||
# Python types | ||
TextIOBase | ||
|
||
# Python packages | ||
pydevd | ||
pyplot | ||
unittest | ||
|
||
# Our "special" words | ||
dirs | ||
iobuf | ||
xyz | ||
|
||
# Python bits | ||
env | ||
|
||
# Misc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
[![Python Actions](https://github.com/SpiNNakerManchester/TestBase/actions/workflows/python_actions.yml/badge.svg?branch=main)](https://github.com/SpiNNakerManchester/TestBase/actions/workflows/python_actions.yml) [![Coverage Status](https://coveralls.io/repos/github/SpiNNakerManchester/TestBase/badge.svg)](https://coveralls.io/github/SpiNNakerManchester/TestBase) | ||
|
||
This Repository hold classes and script used for integration tests | ||
This Repository hold classes and script used for unit and integration tests | ||
|
||
There is need to use this repository unless you want to run some or all integration tests locally | ||
There is need to use this repository unless you want to run some or all tests locally | ||
|
||
Documentation | ||
------------- | ||
[TestBase documentation](https://spinnakertestbase.readthedocs.io/) | ||
|
||
[Combined PyNN8 python documentation (Excluding TestBase)](http://spinnakermanchester.readthedocs.io) | ||
[Combined python documentation (Excluding TestBase)](http://spinnakermanchester.readthedocs.io) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright (c) 2018 The University of Manchester | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import platform | ||
import subprocess | ||
import time | ||
from typing import Set | ||
|
||
|
||
class Ping(object): | ||
""" | ||
Platform-independent ping support. | ||
""" | ||
|
||
#: The unreachable host cache. | ||
unreachable: Set[str] = set() | ||
|
||
@staticmethod | ||
def ping(ip_address): | ||
""" | ||
Send a ping (ICMP ECHO request) to the given host. | ||
SpiNNaker boards support ICMP ECHO when booted. | ||
:param str ip_address: | ||
The IP address to ping. Hostnames can be used, but are not | ||
recommended. | ||
:return: | ||
return code of subprocess; 0 for success, anything else for failure | ||
:rtype: int | ||
""" | ||
if platform.platform().lower().startswith("windows"): | ||
cmd = "ping -n 1 -w 1 " | ||
else: | ||
cmd = "ping -c 1 -W 1 " | ||
process = subprocess.Popen( | ||
cmd + ip_address, shell=True, stdout=subprocess.PIPE) | ||
time.sleep(1.2) | ||
process.stdout.close() | ||
process.wait() | ||
return process.returncode | ||
|
||
@staticmethod | ||
def host_is_reachable(ip_address): | ||
""" | ||
Test if a host is unreachable via ICMP ECHO. | ||
.. note:: | ||
This information may be cached in various ways. Transient failures | ||
are not necessarily detected or recovered from. | ||
:param str ip_address: | ||
The IP address to ping. Hostnames can be used, but are not | ||
recommended. | ||
:rtype: bool | ||
""" | ||
if ip_address in Ping.unreachable: | ||
return False | ||
tries = 0 | ||
while True: | ||
if Ping.ping(ip_address) == 0: | ||
return True | ||
tries += 1 | ||
if tries > 10: | ||
Ping.unreachable.add(ip_address) | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.