mirror of
https://github.com/ep1cman/unifi-protect-backup.git
synced 2025-12-24 04:04:44 +00:00
Rename RCloneException to more general SubprocessException
This commit is contained in:
@@ -16,7 +16,7 @@ from pyunifiprotect.data.websocket import WSAction, WSSubscriptionMessage
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RcloneException(Exception):
|
class SubprocessException(Exception):
|
||||||
"""Exception class for when rclone does not exit with `0`."""
|
"""Exception class for when rclone does not exit with `0`."""
|
||||||
|
|
||||||
def __init__(self, stdout, stderr, returncode):
|
def __init__(self, stdout, stderr, returncode):
|
||||||
@@ -361,7 +361,7 @@ class UnifiProtectBackup:
|
|||||||
"""Check if rclone is installed and the specified remote is configured.
|
"""Check if rclone is installed and the specified remote is configured.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
RcloneException: If rclone is not installed or it failed to list remotes
|
SubprocessException: If rclone is not installed or it failed to list remotes
|
||||||
ValueError: The given rclone destination is for a remote that is not configured
|
ValueError: The given rclone destination is for a remote that is not configured
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -380,7 +380,7 @@ class UnifiProtectBackup:
|
|||||||
logger.extra_debug(f"stdout:\n{stdout.decode()}") # type: ignore
|
logger.extra_debug(f"stdout:\n{stdout.decode()}") # type: ignore
|
||||||
logger.extra_debug(f"stderr:\n{stderr.decode()}") # type: ignore
|
logger.extra_debug(f"stderr:\n{stderr.decode()}") # type: ignore
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
raise RcloneException(stdout.decode(), stderr.decode(), proc.returncode)
|
raise SubprocessException(stdout.decode(), stderr.decode(), proc.returncode)
|
||||||
|
|
||||||
# Check if the destination is for a configured remote
|
# Check if the destination is for a configured remote
|
||||||
for line in stdout.splitlines():
|
for line in stdout.splitlines():
|
||||||
@@ -457,7 +457,7 @@ class UnifiProtectBackup:
|
|||||||
try:
|
try:
|
||||||
await self._upload_video(video, destination, self.rclone_args)
|
await self._upload_video(video, destination, self.rclone_args)
|
||||||
break
|
break
|
||||||
except RcloneException as e:
|
except SubprocessException as e:
|
||||||
logger.warn(f" Failed upload attempt {x+1}, retying in 1s")
|
logger.warn(f" Failed upload attempt {x+1}, retying in 1s")
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
@@ -497,7 +497,7 @@ class UnifiProtectBackup:
|
|||||||
logger.extra_debug(f"stdout:\n{stdout.decode()}") # type: ignore
|
logger.extra_debug(f"stdout:\n{stdout.decode()}") # type: ignore
|
||||||
logger.extra_debug(f"stderr:\n{stderr.decode()}") # type: ignore
|
logger.extra_debug(f"stderr:\n{stderr.decode()}") # type: ignore
|
||||||
else:
|
else:
|
||||||
raise RcloneException(stdout.decode(), stderr.decode(), proc.returncode)
|
raise SubprocessException(stdout.decode(), stderr.decode(), proc.returncode)
|
||||||
|
|
||||||
async def generate_file_path(self, event: Event) -> pathlib.Path:
|
async def generate_file_path(self, event: Event) -> pathlib.Path:
|
||||||
"""Generates the rclone destination path for the provided event.
|
"""Generates the rclone destination path for the provided event.
|
||||||
|
|||||||
Reference in New Issue
Block a user