Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up imports, format file, fix tests, fix errors #472

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions protect_archiver/downloader/download_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 1 addition & 9 deletions protect_archiver/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
2 changes: 1 addition & 1 deletion protect_archiver/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 0 additions & 6 deletions test.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -82,7 +77,6 @@ def calculate_intervals(
yield start, original_end - timedelta(milliseconds=1)



print(
list(
calculate_intervals(
Expand Down
Loading