Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

Commit

Permalink
Removed unused HTTP Consts fixes #255 and Black
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Bradley authored and Robert Bradley committed Nov 10, 2021
1 parent 1c12f05 commit 856bd84
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions custom_components/deepstack_object/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
ATTR_NAME,
CONF_IP_ADDRESS,
CONF_PORT,
HTTP_BAD_REQUEST,
HTTP_OK,
HTTP_UNAUTHORIZED,
)
from homeassistant.core import split_entity_id

Expand Down Expand Up @@ -387,7 +384,8 @@ def process_image(self, image):
if self._save_file_folder:
if self._state > 0 or self._always_save_latest_file:
saved_image_path = self.save_image(
self._targets_found, self._save_file_folder,
self._targets_found,
self._save_file_folder,
)

# Fire events
Expand Down Expand Up @@ -461,7 +459,12 @@ def save_image(self, targets, directory) -> str:
roi_tuple = tuple(self._roi_dict.values())
if roi_tuple != DEFAULT_ROI and self._show_boxes:
draw_box(
draw, roi_tuple, img.width, img.height, text="ROI", color=GREEN,
draw,
roi_tuple,
img.width,
img.height,
text="ROI",
color=GREEN,
)

for obj in targets:
Expand Down Expand Up @@ -491,14 +494,18 @@ def save_image(self, targets, directory) -> str:

# Save images, returning the path of saved image as str
latest_save_path = (
directory / f"{get_valid_filename(self._name).lower()}_latest.{self._save_file_format}"
directory
/ f"{get_valid_filename(self._name).lower()}_latest.{self._save_file_format}"
)
img.save(latest_save_path)
_LOGGER.info("Deepstack saved file %s", latest_save_path)
saved_image_path = latest_save_path

if self._save_timestamped_file:
timestamp_save_path = directory / f"{self._name}_{self._last_detection}.{self._save_file_format}"
timestamp_save_path = (
directory
/ f"{self._name}_{self._last_detection}.{self._save_file_format}"
)
img.save(timestamp_save_path)
_LOGGER.info("Deepstack saved file %s", timestamp_save_path)
saved_image_path = timestamp_save_path
Expand Down

0 comments on commit 856bd84

Please sign in to comment.