Skip to content

Commit

Permalink
Code and documentation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rrooggiieerr committed Dec 8, 2024
1 parent 55a155e commit 04eed18
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions benqprojector/benqprojector.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ def __str__(self):

class BenQProjector(ABC):
"""
BenQProjector class for controlling BenQ projectors.
BenQProjector base class for controlling BenQ projectors.
"""

connection = None
connection: BenQConnection | None = None
# Native networked projectors don't seem to have a command prompt, the code tries to detect if this is the case
has_prompt = None
_separator = b"\n"
Expand Down Expand Up @@ -340,10 +340,7 @@ async def _connect(self) -> bool:
await self.connection.open()
logger.debug("Connected to %s", self.connection)

if self.connected():
return True

return False
return self.connected()

async def connect(self, loop=None, interval: float = None) -> bool:
"""
Expand Down Expand Up @@ -462,10 +459,7 @@ async def connect(self, loop=None, interval: float = None) -> bool:
return True

def connected(self) -> bool:
if self.connection and self.connection.is_open():
return True

return False
return self.connection and self.connection.is_open()

async def _disconnect(self):
await self.connection.close()
Expand Down Expand Up @@ -498,7 +492,7 @@ def _forward_to_listeners(self, command: str, data: Any | None):
listener(command, data)
# pylint: disable=broad-exception-caught
except Exception:
logger.exception("Exception in Callback: %s", listener)
logger.exception("Exception in listener: %s", listener)

async def _cancel_read(self) -> bool:
if self._read_task is not None and not (
Expand Down Expand Up @@ -575,10 +569,6 @@ async def _read_coroutine(self):
except (BrokenPipeError, ConnectionResetError, TimeoutError):
logger.exception("Error communicating with BenQ projector")
await self._disconnect()
# break
except Exception:
logger.exception("Unexpected error")
break

self._read_task = None
logger.debug("Read coroutine stopped")
Expand Down Expand Up @@ -1486,8 +1476,7 @@ class BenQProjectorSerial(BenQProjector):

def __init__(
self,
serial_port: str, # The serial port where the RS-485 interface and
# screen is connected to.
serial_port: str,
baud_rate: int,
model_hint: str = None,
strict_validation: bool = False,
Expand Down

0 comments on commit 04eed18

Please sign in to comment.