Replaces IOError by OSError (#26428)
This commit is contained in:
parent
4004879ae0
commit
0df1b4c7a1
20 changed files with 24 additions and 24 deletions
|
@ -216,7 +216,7 @@ def check_pid(pid_file: str) -> None:
|
||||||
try:
|
try:
|
||||||
with open(pid_file, "r") as file:
|
with open(pid_file, "r") as file:
|
||||||
pid = int(file.readline())
|
pid = int(file.readline())
|
||||||
except IOError:
|
except OSError:
|
||||||
# PID File does not exist
|
# PID File does not exist
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ def write_pid(pid_file: str) -> None:
|
||||||
try:
|
try:
|
||||||
with open(pid_file, "w") as file:
|
with open(pid_file, "w") as file:
|
||||||
file.write(str(pid))
|
file.write(str(pid))
|
||||||
except IOError:
|
except OSError:
|
||||||
print(f"Fatal Error: Unable to write pid file {pid_file}")
|
print(f"Fatal Error: Unable to write pid file {pid_file}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ def closefds_osx(min_fd: int, max_fd: int) -> None:
|
||||||
val = fcntl(_fd, F_GETFD)
|
val = fcntl(_fd, F_GETFD)
|
||||||
if not val & FD_CLOEXEC:
|
if not val & FD_CLOEXEC:
|
||||||
fcntl(_fd, F_SETFD, val | FD_CLOEXEC)
|
fcntl(_fd, F_SETFD, val | FD_CLOEXEC)
|
||||||
except IOError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ def _setup_bme680(config):
|
||||||
sensor.select_gas_heater_profile(0)
|
sensor.select_gas_heater_profile(0)
|
||||||
else:
|
else:
|
||||||
sensor.set_gas_status(bme680.DISABLE_GAS_MEAS)
|
sensor.set_gas_status(bme680.DISABLE_GAS_MEAS)
|
||||||
except (RuntimeError, IOError):
|
except (RuntimeError, OSError):
|
||||||
_LOGGER.error("BME680 sensor not detected at 0x%02x", i2c_address)
|
_LOGGER.error("BME680 sensor not detected at 0x%02x", i2c_address)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ class BMWConnectedDriveAccount:
|
||||||
self.account.update_vehicle_states()
|
self.account.update_vehicle_states()
|
||||||
for listener in self._update_listeners:
|
for listener in self._update_listeners:
|
||||||
listener()
|
listener()
|
||||||
except IOError as exception:
|
except OSError as exception:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Could not connect to the BMW Connected Drive portal. "
|
"Could not connect to the BMW Connected Drive portal. "
|
||||||
"The vehicle state could not be updated."
|
"The vehicle state could not be updated."
|
||||||
|
|
|
@ -110,7 +110,7 @@ def setup(hass, config):
|
||||||
server = egardiaserver.EgardiaServer("", rs_port)
|
server = egardiaserver.EgardiaServer("", rs_port)
|
||||||
bound = server.bind()
|
bound = server.bind()
|
||||||
if not bound:
|
if not bound:
|
||||||
raise IOError(
|
raise OSError(
|
||||||
"Binding error occurred while " + "starting EgardiaServer."
|
"Binding error occurred while " + "starting EgardiaServer."
|
||||||
)
|
)
|
||||||
hass.data[EGARDIA_SERVER] = server
|
hass.data[EGARDIA_SERVER] = server
|
||||||
|
@ -123,7 +123,7 @@ def setup(hass, config):
|
||||||
# listen to home assistant stop event
|
# listen to home assistant stop event
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, handle_stop_event)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, handle_stop_event)
|
||||||
|
|
||||||
except IOError:
|
except OSError:
|
||||||
_LOGGER.error("Binding error occurred while starting EgardiaServer")
|
_LOGGER.error("Binding error occurred while starting EgardiaServer")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -293,7 +293,7 @@ class HangoutsBot:
|
||||||
if self.hass.config.is_allowed_path(uri):
|
if self.hass.config.is_allowed_path(uri):
|
||||||
try:
|
try:
|
||||||
image_file = open(uri, "rb")
|
image_file = open(uri, "rb")
|
||||||
except IOError as error:
|
except OSError as error:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Image file I/O error(%s): %s", error.errno, error.strerror
|
"Image file I/O error(%s): %s", error.errno, error.strerror
|
||||||
)
|
)
|
||||||
|
|
|
@ -157,7 +157,7 @@ class KeyboardRemoteThread(threading.Thread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
event = self.dev.read_one()
|
event = self.dev.read_one()
|
||||||
except IOError: # Keyboard Disconnected
|
except OSError: # Keyboard Disconnected
|
||||||
self.dev = None
|
self.dev = None
|
||||||
self.hass.bus.fire(
|
self.hass.bus.fire(
|
||||||
KEYBOARD_REMOTE_DISCONNECTED,
|
KEYBOARD_REMOTE_DISCONNECTED,
|
||||||
|
|
|
@ -70,7 +70,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
try:
|
try:
|
||||||
device = LiveboxPlayTvDevice(host, port, name)
|
device = LiveboxPlayTvDevice(host, port, name)
|
||||||
livebox_devices.append(device)
|
livebox_devices.append(device)
|
||||||
except IOError:
|
except OSError:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Failed to connect to Livebox Play TV at %s:%s. "
|
"Failed to connect to Livebox Play TV at %s:%s. "
|
||||||
"Please check your configuration",
|
"Please check your configuration",
|
||||||
|
|
|
@ -157,7 +157,7 @@ class MiFloraSensor(Entity):
|
||||||
try:
|
try:
|
||||||
_LOGGER.debug("Polling data for %s", self.name)
|
_LOGGER.debug("Polling data for %s", self.name)
|
||||||
data = self.poller.parameter_value(self.parameter)
|
data = self.poller.parameter_value(self.parameter)
|
||||||
except IOError as ioerr:
|
except OSError as ioerr:
|
||||||
_LOGGER.info("Polling error %s", ioerr)
|
_LOGGER.info("Polling error %s", ioerr)
|
||||||
return
|
return
|
||||||
except BluetoothBackendException as bterror:
|
except BluetoothBackendException as bterror:
|
||||||
|
|
|
@ -157,7 +157,7 @@ class MiTempBtSensor(Entity):
|
||||||
try:
|
try:
|
||||||
_LOGGER.debug("Polling data for %s", self.name)
|
_LOGGER.debug("Polling data for %s", self.name)
|
||||||
data = self.poller.parameter_value(self.parameter)
|
data = self.poller.parameter_value(self.parameter)
|
||||||
except IOError as ioerr:
|
except OSError as ioerr:
|
||||||
_LOGGER.warning("Polling error %s", ioerr)
|
_LOGGER.warning("Polling error %s", ioerr)
|
||||||
return
|
return
|
||||||
except BluetoothBackendException as bterror:
|
except BluetoothBackendException as bterror:
|
||||||
|
|
|
@ -92,7 +92,7 @@ def setup(hass, config):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pilight_client.send_code(message_data)
|
pilight_client.send_code(message_data)
|
||||||
except IOError:
|
except OSError:
|
||||||
_LOGGER.error("Pilight send failed for %s", str(message_data))
|
_LOGGER.error("Pilight send failed for %s", str(message_data))
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_NAME, send_code, schema=RF_CODE_SCHEMA)
|
hass.services.register(DOMAIN, SERVICE_NAME, send_code, schema=RF_CODE_SCHEMA)
|
||||||
|
|
|
@ -66,7 +66,7 @@ def _precheck_image(image, opts):
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
try:
|
try:
|
||||||
img = Image.open(io.BytesIO(image))
|
img = Image.open(io.BytesIO(image))
|
||||||
except IOError:
|
except OSError:
|
||||||
_LOGGER.warning("Failed to open image")
|
_LOGGER.warning("Failed to open image")
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
imgfmt = str(img.format)
|
imgfmt = str(img.format)
|
||||||
|
|
|
@ -47,7 +47,7 @@ def setup_input(address, port, pull_mode, bouncetime):
|
||||||
bounce_time=bouncetime,
|
bounce_time=bouncetime,
|
||||||
pin_factory=PiGPIOFactory(address),
|
pin_factory=PiGPIOFactory(address),
|
||||||
)
|
)
|
||||||
except (ValueError, IndexError, KeyError, IOError):
|
except (ValueError, IndexError, KeyError, OSError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
button = remote_rpi_gpio.setup_input(
|
button = remote_rpi_gpio.setup_input(
|
||||||
address, port_num, pull_mode, bouncetime
|
address, port_num, pull_mode, bouncetime
|
||||||
)
|
)
|
||||||
except (ValueError, IndexError, KeyError, IOError):
|
except (ValueError, IndexError, KeyError, OSError):
|
||||||
return
|
return
|
||||||
new_sensor = RemoteRPiGPIOBinarySensor(port_name, button, invert_logic)
|
new_sensor = RemoteRPiGPIOBinarySensor(port_name, button, invert_logic)
|
||||||
devices.append(new_sensor)
|
devices.append(new_sensor)
|
||||||
|
|
|
@ -36,7 +36,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
for port, name in ports.items():
|
for port, name in ports.items():
|
||||||
try:
|
try:
|
||||||
led = remote_rpi_gpio.setup_output(address, port, invert_logic)
|
led = remote_rpi_gpio.setup_output(address, port, invert_logic)
|
||||||
except (ValueError, IndexError, KeyError, IOError):
|
except (ValueError, IndexError, KeyError, OSError):
|
||||||
return
|
return
|
||||||
new_switch = RemoteRPiGPIOSwitch(name, led, invert_logic)
|
new_switch = RemoteRPiGPIOSwitch(name, led, invert_logic)
|
||||||
devices.append(new_switch)
|
devices.append(new_switch)
|
||||||
|
|
|
@ -94,7 +94,7 @@ def _parse_skyhub_response(data_str):
|
||||||
"""Parse the Sky Hub data format."""
|
"""Parse the Sky Hub data format."""
|
||||||
pattmatch = re.search("attach_dev = '(.*)'", data_str)
|
pattmatch = re.search("attach_dev = '(.*)'", data_str)
|
||||||
if pattmatch is None:
|
if pattmatch is None:
|
||||||
raise IOError(
|
raise OSError(
|
||||||
"Error: Impossible to fetch data from"
|
"Error: Impossible to fetch data from"
|
||||||
+ " Sky Hub. Try to reboot the router."
|
+ " Sky Hub. Try to reboot the router."
|
||||||
)
|
)
|
||||||
|
|
|
@ -65,7 +65,7 @@ def setup(hass, base_config):
|
||||||
srv_info,
|
srv_info,
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
except IOError:
|
except OSError:
|
||||||
_LOGGER.exception(
|
_LOGGER.exception(
|
||||||
"Server: %s not configured. Error on Supla API access: ", server_address
|
"Server: %s not configured. Error on Supla API access: ", server_address
|
||||||
)
|
)
|
||||||
|
|
|
@ -117,7 +117,7 @@ class TelnetSwitch(SwitchDevice):
|
||||||
response = telnet.read_until(b"\r", timeout=self._timeout)
|
response = telnet.read_until(b"\r", timeout=self._timeout)
|
||||||
_LOGGER.debug("telnet response: %s", response.decode("ASCII").strip())
|
_LOGGER.debug("telnet response: %s", response.decode("ASCII").strip())
|
||||||
return response.decode("ASCII").strip()
|
return response.decode("ASCII").strip()
|
||||||
except IOError as error:
|
except OSError as error:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
'Command "%s" failed with exception: %s', command, repr(error)
|
'Command "%s" failed with exception: %s', command, repr(error)
|
||||||
)
|
)
|
||||||
|
|
|
@ -96,7 +96,7 @@ class TemperSensor(Entity):
|
||||||
)
|
)
|
||||||
sensor_value = self.temper_device.get_temperature(format_str)
|
sensor_value = self.temper_device.get_temperature(format_str)
|
||||||
self.current_value = round(sensor_value, 1)
|
self.current_value = round(sensor_value, 1)
|
||||||
except IOError:
|
except OSError:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Failed to get temperature. The device address may"
|
"Failed to get temperature. The device address may"
|
||||||
"have changed. Attempting to reset device"
|
"have changed. Attempting to reset device"
|
||||||
|
|
|
@ -289,7 +289,7 @@ def _write_default_config(config_dir: str) -> Optional[str]:
|
||||||
|
|
||||||
return config_path
|
return config_path
|
||||||
|
|
||||||
except IOError:
|
except OSError:
|
||||||
print("Unable to create default configuration file", config_path)
|
print("Unable to create default configuration file", config_path)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ def process_ha_config_upgrade(hass: HomeAssistant) -> None:
|
||||||
try:
|
try:
|
||||||
with open(config_path, "wt", encoding="utf-8") as config_file:
|
with open(config_path, "wt", encoding="utf-8") as config_file:
|
||||||
config_file.write(config_raw)
|
config_file.write(config_raw)
|
||||||
except IOError:
|
except OSError:
|
||||||
_LOGGER.exception("Migrating to google_translate tts failed")
|
_LOGGER.exception("Migrating to google_translate tts failed")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ def install_osx():
|
||||||
try:
|
try:
|
||||||
with open(path, "w", encoding="utf-8") as outp:
|
with open(path, "w", encoding="utf-8") as outp:
|
||||||
outp.write(plist)
|
outp.write(plist)
|
||||||
except IOError as err:
|
except OSError as err:
|
||||||
print("Unable to write to " + path, err)
|
print("Unable to write to " + path, err)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue