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

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 

11 

12from __future__ import ( 

13 unicode_literals, 

14 print_function, 

15 absolute_import, 

16 division, 

17) 

18str = type('') 

19 

20 

21class GPIOZeroError(Exception): 

22 "Base class for all exceptions in GPIO Zero" 

23 

24class DeviceClosed(GPIOZeroError): 

25 "Error raised when an operation is attempted on a closed device" 

26 

27class BadEventHandler(GPIOZeroError, ValueError): 

28 "Error raised when an event handler with an incompatible prototype is specified" 

29 

30class BadWaitTime(GPIOZeroError, ValueError): 

31 "Error raised when an invalid wait time is specified" 

32 

33class BadQueueLen(GPIOZeroError, ValueError): 

34 "Error raised when non-positive queue length is specified" 

35 

36class BadPinFactory(GPIOZeroError, ImportError): 

37 "Error raised when an unknown pin factory name is specified" 

38 

39class ZombieThread(GPIOZeroError, RuntimeError): 

40 "Error raised when a thread fails to die within a given timeout" 

41 

42class CompositeDeviceError(GPIOZeroError): 

43 "Base class for errors specific to the CompositeDevice hierarchy" 

44 

45class CompositeDeviceBadName(CompositeDeviceError, ValueError): 

46 "Error raised when a composite device is constructed with a reserved name" 

47 

48class CompositeDeviceBadOrder(CompositeDeviceError, ValueError): 

49 "Error raised when a composite device is constructed with an incomplete order" 

50 

51class CompositeDeviceBadDevice(CompositeDeviceError, ValueError): 

52 "Error raised when a composite device is constructed with an object that doesn't inherit from :class:`Device`" 

53 

54class EnergenieSocketMissing(CompositeDeviceError, ValueError): 

55 "Error raised when socket number is not specified" 

56 

57class EnergenieBadSocket(CompositeDeviceError, ValueError): 

58 "Error raised when an invalid socket number is passed to :class:`Energenie`" 

59 

60class SPIError(GPIOZeroError): 

61 "Base class for errors related to the SPI implementation" 

62 

63class SPIBadArgs(SPIError, ValueError): 

64 "Error raised when invalid arguments are given while constructing :class:`SPIDevice`" 

65 

66class SPIBadChannel(SPIError, ValueError): 

67 "Error raised when an invalid channel is given to an :class:`AnalogInputDevice`" 

68 

69class SPIFixedClockMode(SPIError, AttributeError): 

70 "Error raised when the SPI clock mode cannot be changed" 

71 

72class SPIInvalidClockMode(SPIError, ValueError): 

73 "Error raised when an invalid clock mode is given to an SPI implementation" 

74 

75class SPIFixedBitOrder(SPIError, AttributeError): 

76 "Error raised when the SPI bit-endianness cannot be changed" 

77 

78class SPIFixedSelect(SPIError, AttributeError): 

79 "Error raised when the SPI select polarity cannot be changed" 

80 

81class SPIFixedWordSize(SPIError, AttributeError): 

82 "Error raised when the number of bits per word cannot be changed" 

83 

84class SPIFixedRate(SPIError, AttributeError): 

85 "Error raised when the baud-rate of the interface cannot be changed" 

86 

87class SPIInvalidWordSize(SPIError, ValueError): 

88 "Error raised when an invalid (out of range) number of bits per word is specified" 

89 

90class GPIODeviceError(GPIOZeroError): 

91 "Base class for errors specific to the GPIODevice hierarchy" 

92 

93class GPIODeviceClosed(GPIODeviceError, DeviceClosed): 

94 "Deprecated descendent of :exc:`DeviceClosed`" 

95 

96class GPIOPinInUse(GPIODeviceError): 

97 "Error raised when attempting to use a pin already in use by another device" 

98 

99class GPIOPinMissing(GPIODeviceError, ValueError): 

100 "Error raised when a pin specification is not given" 

101 

102class InputDeviceError(GPIODeviceError): 

103 "Base class for errors specific to the InputDevice hierarchy" 

104 

105class OutputDeviceError(GPIODeviceError): 

106 "Base class for errors specified to the OutputDevice hierarchy" 

107 

108class OutputDeviceBadValue(OutputDeviceError, ValueError): 

109 "Error raised when ``value`` is set to an invalid value" 

110 

111class PinError(GPIOZeroError): 

112 "Base class for errors related to pin implementations" 

113 

114class PinInvalidFunction(PinError, ValueError): 

115 "Error raised when attempting to change the function of a pin to an invalid value" 

116 

117class PinInvalidState(PinError, ValueError): 

118 "Error raised when attempting to assign an invalid state to a pin" 

119 

120class PinInvalidPull(PinError, ValueError): 

121 "Error raised when attempting to assign an invalid pull-up to a pin" 

122 

123class PinInvalidEdges(PinError, ValueError): 

124 "Error raised when attempting to assign an invalid edge detection to a pin" 

125 

126class PinInvalidBounce(PinError, ValueError): 

127 "Error raised when attempting to assign an invalid bounce time to a pin" 

128 

129class PinSetInput(PinError, AttributeError): 

130 "Error raised when attempting to set a read-only pin" 

131 

132class PinFixedPull(PinError, AttributeError): 

133 "Error raised when attempting to set the pull of a pin with fixed pull-up" 

134 

135class PinEdgeDetectUnsupported(PinError, AttributeError): 

136 "Error raised when attempting to use edge detection on unsupported pins" 

137 

138class PinUnsupported(PinError, NotImplementedError): 

139 "Error raised when attempting to obtain a pin interface on unsupported pins" 

140 

141class PinSPIUnsupported(PinError, NotImplementedError): 

142 "Error raised when attempting to obtain an SPI interface on unsupported pins" 

143 

144class PinPWMError(PinError): 

145 "Base class for errors related to PWM implementations" 

146 

147class PinPWMUnsupported(PinPWMError, AttributeError): 

148 "Error raised when attempting to activate PWM on unsupported pins" 

149 

150class PinPWMFixedValue(PinPWMError, AttributeError): 

151 "Error raised when attempting to initialize PWM on an input pin" 

152 

153class PinUnknownPi(PinError, RuntimeError): 

154 "Error raised when gpiozero doesn't recognize a revision of the Pi" 

155 

156class PinMultiplePins(PinError, RuntimeError): 

157 "Error raised when multiple pins support the requested function" 

158 

159class PinNoPins(PinError, RuntimeError): 

160 "Error raised when no pins support the requested function" 

161 

162class PinInvalidPin(PinError, ValueError): 

163 "Error raised when an invalid pin specification is provided" 

164 

165class GPIOZeroWarning(Warning): 

166 "Base class for all warnings in GPIO Zero" 

167 

168class DistanceSensorNoEcho(GPIOZeroWarning): 

169 "Warning raised when the distance sensor sees no echo at all" 

170 

171class SPIWarning(GPIOZeroWarning): 

172 "Base class for warnings related to the SPI implementation" 

173 

174class SPISoftwareFallback(SPIWarning): 

175 "Warning raised when falling back to the SPI software implementation" 

176 

177class PWMWarning(GPIOZeroWarning): 

178 "Base class for PWM warnings" 

179 

180class PWMSoftwareFallback(PWMWarning): 

181 "Warning raised when falling back to the PWM software implementation" 

182 

183class PinWarning(GPIOZeroWarning): 

184 "Base class for warnings related to pin implementations" 

185 

186class PinFactoryFallback(PinWarning): 

187 "Warning raised when a default pin factory fails to load and a fallback is tried" 

188 

189class NativePinFactoryFallback(PinWarning): 

190 "Warning raised when all other default pin factories fail to load and NativeFactory is used" 

191 

192class PinNonPhysical(PinWarning): 

193 "Warning raised when a non-physical pin is specified in a constructor" 

194 

195class ThresholdOutOfRange(GPIOZeroWarning): 

196 "Warning raised when a threshold is out of range specified by min and max values" 

197 

198class CallbackSetToNone(GPIOZeroWarning): 

199 "Warning raised when a callback is set to None when its previous value was None" 

200 

201class AmbiguousTone(GPIOZeroWarning): 

202 "Warning raised when a Tone is constructed with an ambiguous number"