-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from andrewsayre/dev
v0.6.0
- Loading branch information
Showing
11 changed files
with
169 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
"""pyheos - a library for interacting with HEOS devices.""" | ||
from . import const | ||
from .dispatch import Dispatcher | ||
from .error import CommandError, CommandFailedError, HeosError | ||
from .group import HeosGroup | ||
from .heos import Heos | ||
from .player import HeosNowPlayingMedia, HeosPlayer | ||
from .response import CommandError | ||
from .source import HeosSource, InputSource | ||
|
||
__all__ = [ | ||
'const', | ||
'CommandError', | ||
'CommandFailedError', | ||
'Dispatcher', | ||
'Heos', | ||
'HeosError', | ||
'HeosGroup', | ||
'HeosPlayer', | ||
'HeosNowPlayingMedia', | ||
'HeosSource', | ||
'InputSource' | ||
'InputSource', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"""Define the error module for HEOS.""" | ||
import asyncio | ||
|
||
DEFAULT_ERROR_MESSAGES = { | ||
asyncio.TimeoutError: "Command timed out", | ||
ConnectionError: "Connection error", | ||
BrokenPipeError: "Broken pipe", | ||
ConnectionAbortedError: "Connection aborted", | ||
ConnectionRefusedError: "Connection refused", | ||
ConnectionResetError: "Connection reset", | ||
OSError: "OS I/O error" | ||
} | ||
|
||
|
||
def format_error_message(error: Exception) -> str: | ||
"""Format the error message based on a base error.""" | ||
error_message = str(error) | ||
if not error_message: | ||
error_message = DEFAULT_ERROR_MESSAGES.get(type(error)) | ||
return error_message | ||
|
||
|
||
class HeosError(Exception): | ||
"""Define an error from the heos library.""" | ||
|
||
pass | ||
|
||
|
||
class CommandError(HeosError): | ||
"""Define an error command response.""" | ||
|
||
def __init__(self, command: str, message: str): | ||
"""Create a new instance of the error.""" | ||
self._command = command | ||
super().__init__(message) | ||
|
||
@property | ||
def command(self) -> str: | ||
"""Get the command that raised the error.""" | ||
return self._command | ||
|
||
|
||
class CommandFailedError(CommandError): | ||
"""Define an error when a HEOS command fails.""" | ||
|
||
def __init__(self, command: str, text: str, error_id: int): | ||
"""Create a new instance of the error.""" | ||
self._command = command | ||
self._error_text = text | ||
self._error_id = error_id | ||
super().__init__(command, "{} ({})".format(text, error_id)) | ||
|
||
@property | ||
def error_text(self) -> str: | ||
"""Get the error text from the response.""" | ||
return self._error_text | ||
|
||
@property | ||
def error_id(self) -> int: | ||
"""Return the error id.""" | ||
return self._error_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
log_level=DEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
coveralls==1.7.0 | ||
flake8==3.7.7 | ||
flake8-docstrings==1.3.0 | ||
pydocstyle==3.0.0 | ||
coveralls==1.8.2 | ||
flake8==3.7.8 | ||
flake8-docstrings==1.3.1 | ||
pydocstyle==4.0.1 | ||
pylint==2.3.1 | ||
pytest==4.3.1 | ||
pytest==5.1.1 | ||
pytest-asyncio==0.10.0 | ||
pytest-cov==2.6.1 | ||
pytest-cov==2.7.1 | ||
pytest-timeout==1.3.3 |
Oops, something went wrong.