2023-01-26 07:31:07 +00:00
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
|
2023-05-30 23:53:55 +00:00
|
|
|
import borgmatic.actions.arguments
|
2023-01-26 07:31:07 +00:00
|
|
|
import borgmatic.borg.info
|
|
|
|
import borgmatic.borg.rlist
|
|
|
|
import borgmatic.config.validate
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
def run_info(
|
2023-04-15 02:35:24 +00:00
|
|
|
repository,
|
2023-07-09 06:14:30 +00:00
|
|
|
config,
|
2023-04-15 02:35:24 +00:00
|
|
|
local_borg_version,
|
|
|
|
info_arguments,
|
2023-05-09 06:00:49 +00:00
|
|
|
global_arguments,
|
2023-04-15 02:35:24 +00:00
|
|
|
local_path,
|
|
|
|
remote_path,
|
2023-01-26 07:31:07 +00:00
|
|
|
):
|
|
|
|
'''
|
|
|
|
Run the "info" action for the given repository and archive.
|
|
|
|
|
|
|
|
If info_arguments.json is True, yield the JSON output from the info for the archive.
|
|
|
|
'''
|
|
|
|
if info_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
|
|
|
repository, info_arguments.repository
|
|
|
|
):
|
|
|
|
if not info_arguments.json: # pragma: nocover
|
2023-05-16 16:36:50 +00:00
|
|
|
logger.answer(
|
|
|
|
f'{repository.get("label", repository["path"])}: Displaying archive summary information'
|
|
|
|
)
|
2023-05-30 23:53:55 +00:00
|
|
|
archive_name = borgmatic.borg.rlist.resolve_archive_name(
|
2023-03-24 19:34:57 +00:00
|
|
|
repository['path'],
|
2023-01-26 07:31:07 +00:00
|
|
|
info_arguments.archive,
|
2023-07-09 06:14:30 +00:00
|
|
|
config,
|
2023-01-26 07:31:07 +00:00
|
|
|
local_borg_version,
|
2023-05-09 06:00:49 +00:00
|
|
|
global_arguments,
|
2023-01-26 07:31:07 +00:00
|
|
|
local_path,
|
|
|
|
remote_path,
|
|
|
|
)
|
|
|
|
json_output = borgmatic.borg.info.display_archives_info(
|
2023-03-24 19:34:57 +00:00
|
|
|
repository['path'],
|
2023-07-09 06:14:30 +00:00
|
|
|
config,
|
2023-01-26 07:31:07 +00:00
|
|
|
local_borg_version,
|
2023-05-30 23:53:55 +00:00
|
|
|
borgmatic.actions.arguments.update_arguments(info_arguments, archive=archive_name),
|
2023-05-09 06:00:49 +00:00
|
|
|
global_arguments,
|
|
|
|
local_path,
|
|
|
|
remote_path,
|
2023-01-26 07:31:07 +00:00
|
|
|
)
|
|
|
|
if json_output: # pragma: nocover
|
|
|
|
yield json.loads(json_output)
|