diff --git a/protect_archiver/downloader/download_file.py b/protect_archiver/downloader/download_file.py index 8897c6d..3fa987f 100644 --- a/protect_archiver/downloader/download_file.py +++ b/protect_archiver/downloader/download_file.py @@ -142,14 +142,14 @@ def download_file(client: Any, query: str, filename: str) -> None: os.remove(filename) logging.exception(f"Download failed: {request_exception}") exit_code = 5 - except Errors.DownloadFailed: - # clean up - if os.path.exists(filename): - os.remove(filename) - logging.exception( - f"Download failed with status {response.status_code} {response.reason}" - ) - exit_code = 4 + # except Errors.DownloadFailed: + # # clean up + # if os.path.exists(filename): + # os.remove(filename) + # logging.exception( + # f"Download failed with status {response.status_code} {response.reason}" + # ) + # exit_code = 4 else: return diff --git a/protect_archiver/errors.py b/protect_archiver/errors.py index e19cac6..49801cb 100644 --- a/protect_archiver/errors.py +++ b/protect_archiver/errors.py @@ -2,15 +2,7 @@ class Errors: def __init__(self) -> None: pass - @Exception class ProtectError(Exception): def __init__(self, code: int) -> None: self.code = code - - @Exception - class DownloadFailed(Exception): - pass - - @Exception - class AuthorizationFailed(Exception): - pass + super().__init__(f"ProtectError with code: {code}") diff --git a/protect_archiver/test_client.py b/protect_archiver/test_client.py index 268634c..2f39ef5 100644 --- a/protect_archiver/test_client.py +++ b/protect_archiver/test_client.py @@ -54,7 +54,7 @@ def test_download_footage( ) -> None: responses.add( responses.GET, - "https://unifi:443/proxy/protect/api/video/export?camera=exteriorCameraId&start=1578524400000&end=1578527939000", + "https://unifi:443/proxy/protect/api/video/export?camera=exteriorCameraId&start=1578524400000&end=1578527939999", # 320 bytes of demo data body=( "12572d283469d8c82413787fd73e0c91456c49ea991b2d5bf5e9c87bc3633566" diff --git a/test.py b/test.py index fc9f32a..4fc6cc0 100644 --- a/test.py +++ b/test.py @@ -1,13 +1,8 @@ -import logging -import os - from datetime import datetime from datetime import timedelta -from typing import Any from typing import Iterable from typing import Tuple - import dateutil.parser @@ -82,7 +77,6 @@ def calculate_intervals( yield start, original_end - timedelta(milliseconds=1) - print( list( calculate_intervals(