Skip to content

Commit

Permalink
Remove Extraneous parantheses in exception raising.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Oct 23, 2022
1 parent c601342 commit f3ff58c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions jaraco/abode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def send_request(self, method, path, headers=None, data=None, is_retry=False):

return self.send_request(method, path, headers, data, True)

raise AbodeException((ERROR.REQUEST))
raise AbodeException(ERROR.REQUEST)

@property
def default_mode(self):
Expand Down Expand Up @@ -495,7 +495,7 @@ def new_device(device_json, abode):
type_tag = device_json.get('type_tag')

if not type_tag:
raise AbodeException((ERROR.UNABLE_TO_MAP_DEVICE))
raise AbodeException(ERROR.UNABLE_TO_MAP_DEVICE)

generic_type = CONST.get_generic_type(type_tag.lower())
device_json['generic_type'] = generic_type
Expand Down
4 changes: 2 additions & 2 deletions jaraco/abode/automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def enable(self, enable):
if str(response_object['id']) != str(self._automation['id']) or str(
response_object['enabled']
) != str(self._automation['enabled']):
raise AbodeException((ERROR.INVALID_AUTOMATION_EDIT_RESPONSE))
raise AbodeException(ERROR.INVALID_AUTOMATION_EDIT_RESPONSE)

self.update(response_object)

Expand Down Expand Up @@ -66,7 +66,7 @@ def refresh(self):
response_object = response_object[0]

if str(response_object['id']) != self.automation_id:
raise AbodeException((ERROR.INVALID_AUTOMATION_REFRESH_RESPONSE))
raise AbodeException(ERROR.INVALID_AUTOMATION_REFRESH_RESPONSE)

self.update(response_object)

Expand Down
8 changes: 4 additions & 4 deletions jaraco/abode/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def set_status(self, status):
_LOGGER.debug("Set Status Response: %s", response.text)

if response_object['id'] != self.device_id:
raise AbodeException((ERROR.SET_STATUS_DEV_ID))
raise AbodeException(ERROR.SET_STATUS_DEV_ID)

if response_object['status'] != str(status):
raise AbodeException((ERROR.SET_STATUS_STATE))
raise AbodeException(ERROR.SET_STATUS_STATE)

# Note: Status result is of int type, not of new status of device.
# Seriously, why would you do that?
Expand All @@ -64,10 +64,10 @@ def set_level(self, level):
_LOGGER.debug("Set Level Response: %s", response.text)

if response_object['id'] != self.device_id:
raise AbodeException((ERROR.SET_STATUS_DEV_ID))
raise AbodeException(ERROR.SET_STATUS_DEV_ID)

if response_object['level'] != str(level):
raise AbodeException((ERROR.SET_STATUS_STATE))
raise AbodeException(ERROR.SET_STATUS_STATE)

self.update(response_object)

Expand Down
16 changes: 8 additions & 8 deletions jaraco/abode/devices/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def capture(self):
url = CONST.BASE_URL + self._json_state['control_url']

else:
raise AbodeException((ERROR.MISSING_CONTROL_URL))
raise AbodeException(ERROR.MISSING_CONTROL_URL)

try:
response = self._abode.send_request("put", url)
Expand Down Expand Up @@ -64,13 +64,13 @@ def update_image_location(self, timeline_json):
# Verify that the event code is of the "CAPTURE IMAGE" event
event_code = timeline_json.get('event_code')
if event_code != TIMELINE.CAPTURE_IMAGE['event_code']:
raise AbodeException((ERROR.CAM_TIMELINE_EVENT_INVALID))
raise AbodeException(ERROR.CAM_TIMELINE_EVENT_INVALID)

# The timeline response has an entry for "file_path" that acts as the
# location of the image within the Abode servers.
file_path = timeline_json.get('file_path')
if not file_path:
raise AbodeException((ERROR.CAM_IMAGE_REFRESH_NO_FILE))
raise AbodeException(ERROR.CAM_IMAGE_REFRESH_NO_FILE)

# Perform a "head" request for the image and look for a
# 302 Found response
Expand All @@ -83,13 +83,13 @@ def update_image_location(self, timeline_json):
str(response.status_code),
response.text,
)
raise AbodeException((ERROR.CAM_IMAGE_UNEXPECTED_RESPONSE))
raise AbodeException(ERROR.CAM_IMAGE_UNEXPECTED_RESPONSE)

# The response should have a location header that is the actual
# location of the image stored on AWS
location = response.headers.get('location')
if not location:
raise AbodeException((ERROR.CAM_IMAGE_NO_LOCATION_HEADER))
raise AbodeException(ERROR.CAM_IMAGE_NO_LOCATION_HEADER)

self._image_url = location

Expand All @@ -109,7 +109,7 @@ def image_to_file(self, path, get_image=True):
str(response.status_code),
response.text,
)
raise AbodeException((ERROR.CAM_IMAGE_REQUEST_INVALID))
raise AbodeException(ERROR.CAM_IMAGE_REQUEST_INVALID)

with open(path, 'wb') as imgfile:
copyfileobj(response.raw, imgfile)
Expand Down Expand Up @@ -138,10 +138,10 @@ def privacy_mode(self, enable):
_LOGGER.debug("Camera Privacy Mode Response: %s", response.text)

if response_object['id'] != self.device_id:
raise AbodeException((ERROR.SET_STATUS_DEV_ID))
raise AbodeException(ERROR.SET_STATUS_DEV_ID)

if response_object['privacy'] != str(privacy):
raise AbodeException((ERROR.SET_PRIVACY_MODE))
raise AbodeException(ERROR.SET_PRIVACY_MODE)

_LOGGER.info("Set camera %s privacy mode to: %s", self.device_id, privacy)

Expand Down
4 changes: 2 additions & 2 deletions jaraco/abode/devices/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def set_color_temp(self, color_temp):
_LOGGER.debug("Set Color Temp Response: %s", response.text)

if response_object['idForPanel'] != self.device_id:
raise AbodeException((ERROR.SET_STATUS_DEV_ID))
raise AbodeException(ERROR.SET_STATUS_DEV_ID)

if response_object['colorTemperature'] != int(color_temp):
_LOGGER.warning(
Expand Down Expand Up @@ -70,7 +70,7 @@ def set_color(self, color):
_LOGGER.debug("Set Color Response: %s", response.text)

if response_object['idForPanel'] != self.device_id:
raise AbodeException((ERROR.SET_STATUS_DEV_ID))
raise AbodeException(ERROR.SET_STATUS_DEV_ID)

# Abode will sometimes return hue value off by 1 (rounding error)
hue_comparison = math.isclose(response_object["hue"], int(hue), abs_tol=1)
Expand Down
8 changes: 4 additions & 4 deletions jaraco/abode/event_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def add_device_callback(self, devices, callback):

# Validate the device is valid
if not self._abode.get_device(device_id):
raise AbodeException((ERROR.EVENT_DEVICE_INVALID))
raise AbodeException(ERROR.EVENT_DEVICE_INVALID)

_LOGGER.debug("Subscribing to updates for device_id: %s", device_id)

Expand All @@ -111,7 +111,7 @@ def remove_all_device_callbacks(self, devices):
device_id = device.device_id

if not self._abode.get_device(device_id):
raise AbodeException((ERROR.EVENT_DEVICE_INVALID))
raise AbodeException(ERROR.EVENT_DEVICE_INVALID)

if device_id not in self._device_callbacks:
return False
Expand Down Expand Up @@ -152,12 +152,12 @@ def add_timeline_callback(self, timeline_events, callback):

for timeline_event in timeline_events:
if not isinstance(timeline_event, dict):
raise AbodeException((ERROR.EVENT_CODE_MISSING))
raise AbodeException(ERROR.EVENT_CODE_MISSING)

event_code = timeline_event.get('event_code')

if not event_code:
raise AbodeException((ERROR.EVENT_CODE_MISSING))
raise AbodeException(ERROR.EVENT_CODE_MISSING)

_LOGGER.debug("Subscribing to timeline event: %s", timeline_event)

Expand Down

0 comments on commit f3ff58c

Please sign in to comment.