2023-01-26 07:31:07 +00:00
|
|
|
import logging
|
|
|
|
|
2023-12-20 17:17:41 +00:00
|
|
|
import borgmatic.actions.json
|
2023-01-26 07:31:07 +00:00
|
|
|
import borgmatic.borg.rlist
|
|
|
|
import borgmatic.config.validate
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
def run_rlist(
|
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,
|
|
|
|
rlist_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 "rlist" action for the given repository.
|
|
|
|
|
|
|
|
If rlist_arguments.json is True, yield the JSON output from listing the repository.
|
|
|
|
'''
|
|
|
|
if rlist_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
|
|
|
repository, rlist_arguments.repository
|
|
|
|
):
|
2023-12-20 17:17:41 +00:00
|
|
|
if not rlist_arguments.json:
|
2023-05-16 16:36:50 +00:00
|
|
|
logger.answer(f'{repository.get("label", repository["path"])}: Listing repository')
|
2023-03-24 06:11:14 +00:00
|
|
|
|
2023-01-26 07:31:07 +00:00
|
|
|
json_output = borgmatic.borg.rlist.list_repository(
|
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,
|
|
|
|
rlist_arguments=rlist_arguments,
|
2023-05-09 06:00:49 +00:00
|
|
|
global_arguments=global_arguments,
|
2023-01-26 07:31:07 +00:00
|
|
|
local_path=local_path,
|
|
|
|
remote_path=remote_path,
|
|
|
|
)
|
2023-12-20 17:17:41 +00:00
|
|
|
if json_output:
|
|
|
|
yield borgmatic.actions.json.parse_json(json_output, repository.get('label'))
|