mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
fix various bugs found by the 'prospector' static-analysis tool
This commit is contained in:
@@ -9,7 +9,7 @@ str = type('')
|
||||
import io
|
||||
from collections import namedtuple
|
||||
|
||||
from ..exc import PinUnknownPi, PinMultiplePins
|
||||
from ..exc import PinUnknownPi, PinMultiplePins, PinNoPins
|
||||
|
||||
|
||||
# Some useful constants for describing pins
|
||||
|
||||
@@ -15,7 +15,7 @@ try:
|
||||
except ImportError:
|
||||
from ..compat import isclose
|
||||
|
||||
from . import Pin, PINS_CLEANUP
|
||||
from . import Pin
|
||||
from ..exc import PinSetInput, PinPWMUnsupported, PinFixedPull
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class MockPin(Pin):
|
||||
try:
|
||||
old_pin = cls._PINS[number]
|
||||
except KeyError:
|
||||
self = super(Pin, cls).__new__(cls)
|
||||
self = super(MockPin, cls).__new__(cls)
|
||||
cls._PINS[number] = self
|
||||
self._number = number
|
||||
self._function = 'input'
|
||||
|
||||
@@ -16,6 +16,7 @@ from ..exc import (
|
||||
PinFixedPull,
|
||||
PinInvalidPull,
|
||||
PinInvalidBounce,
|
||||
PinInvalidState,
|
||||
)
|
||||
|
||||
|
||||
@@ -135,7 +136,7 @@ class PiGPIOPin(Pin):
|
||||
if self._host == 'localhost':
|
||||
return "GPIO%d" % self._number
|
||||
else:
|
||||
return "GPIO%d on %s:%d" % (self._host, self._port)
|
||||
return "GPIO%d on %s:%d" % (self._number, self._host, self._port)
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
@@ -182,7 +183,7 @@ class PiGPIOPin(Pin):
|
||||
try:
|
||||
self._connection.set_PWM_dutycycle(self._number, int(value * 255))
|
||||
except pigpio.error:
|
||||
raise PinInvalidValue('invalid state "%s" for pin %r' % (value, self))
|
||||
raise PinInvalidState('invalid state "%s" for pin %r' % (value, self))
|
||||
elif self.function == 'input':
|
||||
raise PinSetInput('cannot set state of pin %r' % self)
|
||||
else:
|
||||
|
||||
@@ -7,8 +7,6 @@ from __future__ import (
|
||||
str = type('')
|
||||
|
||||
|
||||
from threading import Lock
|
||||
|
||||
import RPIO
|
||||
import RPIO.PWM
|
||||
from RPIO.Exceptions import InvalidChannelException
|
||||
@@ -21,6 +19,8 @@ from ..exc import (
|
||||
PinFixedPull,
|
||||
PinInvalidPull,
|
||||
PinInvalidBounce,
|
||||
PinInvalidState,
|
||||
PinPWMError,
|
||||
)
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ class RPIOPin(Pin):
|
||||
|
||||
def _set_state(self, value):
|
||||
if not 0 <= value <= 1:
|
||||
raise PinInvalidValue('invalid state "%s" for pin %r' % (value, self))
|
||||
raise PinInvalidState('invalid state "%s" for pin %r' % (value, self))
|
||||
if self._pwm:
|
||||
RPIO.PWM.clear_channel_gpio(0, self._number)
|
||||
if value == 0:
|
||||
|
||||
Reference in New Issue
Block a user