From 0281fb3123c6057b77d3558e6804c6a6f875efd6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Dec 2020 00:21:46 +0100 Subject: [PATCH] Update to version 0.9.9 --- HELP.md | 2 +- README.md | 4 ++-- README.rst | 2 +- denonavr/__init__.py | 2 +- denonavr/audyssey.py | 30 ++++++++++++------------------ denonavr/denonavr.py | 40 ++++++++++++---------------------------- setup.py | 2 +- 7 files changed, 30 insertions(+), 52 deletions(-) diff --git a/HELP.md b/HELP.md index 5e00da5..7d0b2a1 100644 --- a/HELP.md +++ b/HELP.md @@ -29,7 +29,7 @@ DATA __title__ = 'denonavr' VERSION - 0.9.9.dev1 + 0.9.9 ==================================================================================== diff --git a/README.md b/README.md index f821279..af01674 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # denonavr -[![Version](https://img.shields.io/badge/version-v0.9.9.dev1-orange.svg)](https://github.com/scarface-4711/denonavr) +[![Version](https://img.shields.io/badge/version-v0.9.9-orange.svg)](https://github.com/scarface-4711/denonavr) [![Build Status](https://travis-ci.com/scarface-4711/denonavr.svg?branch=master)](https://travis-ci.com/scarface-4711/denonavr) [![PyPi](https://img.shields.io/pypi/v/denonavr.svg)](https://pypi.org/project/denonavr) [![License](https://img.shields.io/github/license/scarface-4711/denonavr.svg)](LICENSE) -Automation Library for Denon AVR receivers - current version 0.9.9.dev1 +Automation Library for Denon AVR receivers - current version 0.9.9 ## Installation diff --git a/README.rst b/README.rst index 044f3ba..c4c7a40 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ denonavr .. |Build Status| .. image:: https://travis-ci.com/scarface-4711/denonavr.svg?branch=master :target: https://travis-ci.com/scarface-4711/denonavr -Automation Library for Denon AVR receivers - current version 0.9.9.dev1 +Automation Library for Denon AVR receivers - current version 0.9.9 Installation ------------ diff --git a/denonavr/__init__.py b/denonavr/__init__.py index 6065cbc..a68349d 100644 --- a/denonavr/__init__.py +++ b/denonavr/__init__.py @@ -17,7 +17,7 @@ logging.getLogger(__name__).addHandler(logging.NullHandler()) __title__ = "denonavr" -__version__ = "0.9.9.dev1" +__version__ = "0.9.9" def discover(): diff --git a/denonavr/audyssey.py b/denonavr/audyssey.py index eefd72c..1220396 100644 --- a/denonavr/audyssey.py +++ b/denonavr/audyssey.py @@ -15,17 +15,15 @@ _LOGGER = logging.getLogger("Audyssey") MULTI_EQ_MAP = {"0": "Off", "1": "Flat", "2": "L/R Bypass", "3": "Reference"} -MULTI_EQ_MAP_LABELS = dict((value, key) for key, value in MULTI_EQ_MAP.items()) +MULTI_EQ_MAP_LABELS = {(value, key) for key, value in MULTI_EQ_MAP.items()} REF_LVL_OFFSET_MAP = {"0": "0dB", "1": "+5dB", "2": "+10dB", "3": "+15dB"} -REF_LVL_OFFSET_MAP_LABELS = dict( - (value, key) for key, value in REF_LVL_OFFSET_MAP.items() -) +REF_LVL_OFFSET_MAP_LABELS = { + (value, key) for key, value in REF_LVL_OFFSET_MAP.items()} DYNAMIC_VOLUME_MAP = {"0": "Off", "1": "Light", "2": "Medium", "3": "Heavy"} -DYNAMIC_VOLUME_MAP_LABELS = dict( - (value, key) for key, value in DYNAMIC_VOLUME_MAP.items() -) +DYNAMIC_VOLUME_MAP_LABELS = { + (value, key) for key, value in DYNAMIC_VOLUME_MAP.items()} COMMAND_ENDPOINT = "/goform/AppCommand0300.xml" @@ -57,7 +55,7 @@ def send_command(self, xml_tree): xml_tree.write(body, encoding="utf-8", xml_declaration=True) try: result = self.receiver.send_post_command( - command=COMMAND_ENDPOINT, body=body.getvalue()) + COMMAND_ENDPOINT, body.getvalue()) except ConnectTimeout: return except RequestException: @@ -93,7 +91,7 @@ def update(self): ET.SubElement(param_list, "param", name=param) tree = ET.ElementTree(root) - response = self.send_command(xml_tree=tree) + response = self.send_command(tree) if response is None: return False @@ -147,19 +145,18 @@ def _set_audyssey(self, parameter, value): def dynamiceq_off(self): """Turn DynamicEQ off.""" - if self._set_audyssey(parameter="dynamiceq", value=0) is True: + if self._set_audyssey("dynamiceq", 0) is True: self.dynamiceq = False def dynamiceq_on(self): """Turn DynamicEQ on.""" - if self._set_audyssey(parameter="dynamiceq", value=1) is True: + if self._set_audyssey("dynamiceq", 1) is True: self.dynamiceq = True def set_multieq(self, setting): """Set MultiEQ mode.""" if self._set_audyssey( - parameter="multeq", value=MULTI_EQ_MAP_LABELS.get(setting) - ) is True: + "multeq", MULTI_EQ_MAP_LABELS.get(setting)) is True: self.multeq = setting def set_reflevoffset(self, setting): @@ -167,15 +164,12 @@ def set_reflevoffset(self, setting): # Reference level offset can only be used with DynamicEQ if self.dynamiceq is True: if self._set_audyssey( - parameter="reflevoffset", - value=REF_LVL_OFFSET_MAP_LABELS.get(setting) + "reflevoffset", REF_LVL_OFFSET_MAP_LABELS.get(setting) ) is True: self.reflevoffset = setting def set_dynamicvol(self, setting): """Set Dynamic Volume.""" if self._set_audyssey( - parameter="dynamicvol", - value=DYNAMIC_VOLUME_MAP_LABELS.get(setting) - ) is True: + "dynamicvol", DYNAMIC_VOLUME_MAP_LABELS.get(setting)) is True: self.dynamicvol = setting diff --git a/denonavr/denonavr.py b/denonavr/denonavr.py index ab272c7..1f7b8d8 100644 --- a/denonavr/denonavr.py +++ b/denonavr/denonavr.py @@ -424,6 +424,7 @@ def get_status_xml(self, command, suppress_errors=False): raise ValueError from err elif res.status_code == 403: self._handle_403_error(endpoint) + raise ValueError else: if not suppress_errors: _LOGGER.error( @@ -443,6 +444,7 @@ def send_get_command(self, command): return True elif res.status_code == 403: self._handle_403_error(endpoint) + return False else: _LOGGER.error( "Host %s returned HTTP status code %s to GET command at " @@ -2069,9 +2071,7 @@ def _set_tone_control_command(self, parameter_type, value): tree.write(body, encoding="utf-8", xml_declaration=True) try: - self.send_post_command( - command=self._urls.appcommand, body=body.getvalue() - ) + self.send_post_command(self._urls.appcommand, body.getvalue()) except requests.exceptions.RequestException: _LOGGER.error("No connection to %s end point on host %s", self._urls.appcommand, self._host) @@ -2088,7 +2088,7 @@ def enable_tone_control(self): if self._tone_control_adjust is True: return True - elif self._set_tone_control_command(parameter_type='adjust', value=1): + elif self._set_tone_control_command('adjust', 1): self._tone_control_adjust = True return True return False @@ -2100,7 +2100,7 @@ def disable_tone_control(self): if self._tone_control_adjust is False: return True - elif self._set_tone_control_command(parameter_type='adjust', value=0): + elif self._set_tone_control_command('adjust', 0): self._tone_control_adjust = False return True return False @@ -2108,34 +2108,18 @@ def disable_tone_control(self): def _set_tone_control(self, parameter_type, value): """Set tone control parameter.""" if value < 0 or value > 12: - raise ValueError( - "Invalid value for {parameter_type}".format( - parameter_type=parameter_type - ) - ) + raise ValueError("Invalid value for {}".format(parameter_type)) if not self.enable_tone_control(): return False if self._set_tone_control_command( - parameter_type='{parameter_type}value'.format( - parameter_type=parameter_type - ), value=value - ): - setattr( - self, - '_{parameter_type}'.format(parameter_type=parameter_type), - value - ) + '{}value'.format(parameter_type), value): + setattr(self, '_{}'.format(parameter_type), value) setattr( - self, - '_{parameter_type}_level'.format( - parameter_type=parameter_type - ), + self, '_{}_level'.format(parameter_type), '{value:{sign}}dB'.format( - value=value-6, sign='' if value-6 == 0 else '+' - ) - ) + value=value-6, sign='' if value-6 == 0 else '+')) return True return False @@ -2148,7 +2132,7 @@ def set_bass(self, bass): Note: Doesn't work, if Dynamic Equalizer is active. """ - return self._set_tone_control(parameter_type='bass', value=bass) + return self._set_tone_control('bass', bass) def set_treble(self, treble): """ @@ -2159,7 +2143,7 @@ def set_treble(self, treble): Note: Doesn't work, if Dynamic Equalizer is active. """ - return self._set_tone_control(parameter_type='treble', value=treble) + return self._set_tone_control('treble', treble) class DenonAVRZones(DenonAVR): diff --git a/setup.py b/setup.py index 38b3dc3..ad70592 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import find_packages, setup setup(name='denonavr', - version='0.9.9.dev1', + version='0.9.9', description='Automation Library for Denon AVR receivers', long_description='Automation Library for Denon AVR receivers', url='https://github.com/scarface-4711/denonavr',