Skip to content

Commit

Permalink
Check on data structure included
Browse files Browse the repository at this point in the history
  • Loading branch information
chomupashchuk authored Jan 30, 2021
1 parent a4e42ab commit 56a8f09
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions delete/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def handle_delete_file(call):
"""Handle the service call."""
file_path = call.data.get(ATTR_FILE, DEFAULT_FILE)

if file_path == DEFAULT_FILE:
_LOGGER.error("Value of 'file' was not detected. Check the syntax of the service.")
raise Exception("Value of 'file' was not detected. Check the syntax of the service.")

if os.path.isfile(file_path):
_rem_file(file_path)
elif os.path.isdir(file_path):
Expand All @@ -67,6 +71,10 @@ def handle_delete_files_in_folder(call):
delete_folders = call.data.get(ATTR_DEL_FOLDERS, False)
now = time.time()

if folder_path == DEFAULT_FOLDER:
_LOGGER.error("Value of 'folder' was not detected. Check the syntax of the service.")
raise Exception("Value of 'folder' was not detected. Check the syntax of the service.")

except_extensions = []
if isinstance(exceptions, str):
except_extensions.append(exceptions)
Expand Down

0 comments on commit 56a8f09

Please sign in to comment.