Coverage for /usr/lib/python3/dist-packages/gpiozero/exc.py: 100%
63 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-02-10 12:38 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-02-10 12:38 +0000
1# vim: set fileencoding=utf-8:
2#
3# GPIO Zero: a library for controlling the Raspberry Pi's GPIO pins
4#
5# Copyright (c) 2016-2021 Dave Jones <dave@waveform.org.uk>
6# Copyright (c) 2019-2020 Ben Nuttall <ben@bennuttall.com>
7# Copyright (c) 2019 Kosovan Sofiia <sofiia.kosovan@gmail.com>
8# Copyright (c) 2016 Andrew Scheller <github@loowis.durge.org>
9#
10# SPDX-License-Identifier: BSD-3-Clause
12from __future__ import (
13 unicode_literals,
14 print_function,
15 absolute_import,
16 division,
17)
18str = type('')
21class GPIOZeroError(Exception):
22 "Base class for all exceptions in GPIO Zero"
24class DeviceClosed(GPIOZeroError):
25 "Error raised when an operation is attempted on a closed device"
27class BadEventHandler(GPIOZeroError, ValueError):
28 "Error raised when an event handler with an incompatible prototype is specified"
30class BadWaitTime(GPIOZeroError, ValueError):
31 "Error raised when an invalid wait time is specified"
33class BadQueueLen(GPIOZeroError, ValueError):
34 "Error raised when non-positive queue length is specified"
36class BadPinFactory(GPIOZeroError, ImportError):
37 "Error raised when an unknown pin factory name is specified"
39class ZombieThread(GPIOZeroError, RuntimeError):
40 "Error raised when a thread fails to die within a given timeout"
42class CompositeDeviceError(GPIOZeroError):
43 "Base class for errors specific to the CompositeDevice hierarchy"
45class CompositeDeviceBadName(CompositeDeviceError, ValueError):
46 "Error raised when a composite device is constructed with a reserved name"
48class CompositeDeviceBadOrder(CompositeDeviceError, ValueError):
49 "Error raised when a composite device is constructed with an incomplete order"
51class CompositeDeviceBadDevice(CompositeDeviceError, ValueError):
52 "Error raised when a composite device is constructed with an object that doesn't inherit from :class:`Device`"
54class EnergenieSocketMissing(CompositeDeviceError, ValueError):
55 "Error raised when socket number is not specified"
57class EnergenieBadSocket(CompositeDeviceError, ValueError):
58 "Error raised when an invalid socket number is passed to :class:`Energenie`"
60class SPIError(GPIOZeroError):
61 "Base class for errors related to the SPI implementation"
63class SPIBadArgs(SPIError, ValueError):
64 "Error raised when invalid arguments are given while constructing :class:`SPIDevice`"
66class SPIBadChannel(SPIError, ValueError):
67 "Error raised when an invalid channel is given to an :class:`AnalogInputDevice`"
69class SPIFixedClockMode(SPIError, AttributeError):
70 "Error raised when the SPI clock mode cannot be changed"
72class SPIInvalidClockMode(SPIError, ValueError):
73 "Error raised when an invalid clock mode is given to an SPI implementation"
75class SPIFixedBitOrder(SPIError, AttributeError):
76 "Error raised when the SPI bit-endianness cannot be changed"
78class SPIFixedSelect(SPIError, AttributeError):
79 "Error raised when the SPI select polarity cannot be changed"
81class SPIFixedWordSize(SPIError, AttributeError):
82 "Error raised when the number of bits per word cannot be changed"
84class SPIFixedRate(SPIError, AttributeError):
85 "Error raised when the baud-rate of the interface cannot be changed"
87class SPIInvalidWordSize(SPIError, ValueError):
88 "Error raised when an invalid (out of range) number of bits per word is specified"
90class GPIODeviceError(GPIOZeroError):
91 "Base class for errors specific to the GPIODevice hierarchy"
93class GPIODeviceClosed(GPIODeviceError, DeviceClosed):
94 "Deprecated descendent of :exc:`DeviceClosed`"
96class GPIOPinInUse(GPIODeviceError):
97 "Error raised when attempting to use a pin already in use by another device"
99class GPIOPinMissing(GPIODeviceError, ValueError):
100 "Error raised when a pin specification is not given"
102class InputDeviceError(GPIODeviceError):
103 "Base class for errors specific to the InputDevice hierarchy"
105class OutputDeviceError(GPIODeviceError):
106 "Base class for errors specified to the OutputDevice hierarchy"
108class OutputDeviceBadValue(OutputDeviceError, ValueError):
109 "Error raised when ``value`` is set to an invalid value"
111class PinError(GPIOZeroError):
112 "Base class for errors related to pin implementations"
114class PinInvalidFunction(PinError, ValueError):
115 "Error raised when attempting to change the function of a pin to an invalid value"
117class PinInvalidState(PinError, ValueError):
118 "Error raised when attempting to assign an invalid state to a pin"
120class PinInvalidPull(PinError, ValueError):
121 "Error raised when attempting to assign an invalid pull-up to a pin"
123class PinInvalidEdges(PinError, ValueError):
124 "Error raised when attempting to assign an invalid edge detection to a pin"
126class PinInvalidBounce(PinError, ValueError):
127 "Error raised when attempting to assign an invalid bounce time to a pin"
129class PinSetInput(PinError, AttributeError):
130 "Error raised when attempting to set a read-only pin"
132class PinFixedPull(PinError, AttributeError):
133 "Error raised when attempting to set the pull of a pin with fixed pull-up"
135class PinEdgeDetectUnsupported(PinError, AttributeError):
136 "Error raised when attempting to use edge detection on unsupported pins"
138class PinUnsupported(PinError, NotImplementedError):
139 "Error raised when attempting to obtain a pin interface on unsupported pins"
141class PinSPIUnsupported(PinError, NotImplementedError):
142 "Error raised when attempting to obtain an SPI interface on unsupported pins"
144class PinPWMError(PinError):
145 "Base class for errors related to PWM implementations"
147class PinPWMUnsupported(PinPWMError, AttributeError):
148 "Error raised when attempting to activate PWM on unsupported pins"
150class PinPWMFixedValue(PinPWMError, AttributeError):
151 "Error raised when attempting to initialize PWM on an input pin"
153class PinUnknownPi(PinError, RuntimeError):
154 "Error raised when gpiozero doesn't recognize a revision of the Pi"
156class PinMultiplePins(PinError, RuntimeError):
157 "Error raised when multiple pins support the requested function"
159class PinNoPins(PinError, RuntimeError):
160 "Error raised when no pins support the requested function"
162class PinInvalidPin(PinError, ValueError):
163 "Error raised when an invalid pin specification is provided"
165class GPIOZeroWarning(Warning):
166 "Base class for all warnings in GPIO Zero"
168class DistanceSensorNoEcho(GPIOZeroWarning):
169 "Warning raised when the distance sensor sees no echo at all"
171class SPIWarning(GPIOZeroWarning):
172 "Base class for warnings related to the SPI implementation"
174class SPISoftwareFallback(SPIWarning):
175 "Warning raised when falling back to the SPI software implementation"
177class PWMWarning(GPIOZeroWarning):
178 "Base class for PWM warnings"
180class PWMSoftwareFallback(PWMWarning):
181 "Warning raised when falling back to the PWM software implementation"
183class PinWarning(GPIOZeroWarning):
184 "Base class for warnings related to pin implementations"
186class PinFactoryFallback(PinWarning):
187 "Warning raised when a default pin factory fails to load and a fallback is tried"
189class NativePinFactoryFallback(PinWarning):
190 "Warning raised when all other default pin factories fail to load and NativeFactory is used"
192class PinNonPhysical(PinWarning):
193 "Warning raised when a non-physical pin is specified in a constructor"
195class ThresholdOutOfRange(GPIOZeroWarning):
196 "Warning raised when a threshold is out of range specified by min and max values"
198class CallbackSetToNone(GPIOZeroWarning):
199 "Warning raised when a callback is set to None when its previous value was None"
201class AmbiguousTone(GPIOZeroWarning):
202 "Warning raised when a Tone is constructed with an ambiguous number"