2018-05-26 23:19:05 +00:00
|
|
|
import logging
|
2019-04-03 05:30:14 +00:00
|
|
|
|
|
|
|
from borgmatic.borg.execute import execute_command
|
2019-05-12 09:30:22 +00:00
|
|
|
from borgmatic.logger import get_logger
|
2018-05-26 23:19:05 +00:00
|
|
|
|
2019-05-12 09:30:22 +00:00
|
|
|
logger = get_logger(__name__)
|
2018-05-26 23:19:05 +00:00
|
|
|
|
|
|
|
|
2018-09-30 05:45:00 +00:00
|
|
|
def display_archives_info(
|
|
|
|
repository, storage_config, local_path='borg', remote_path=None, json=False
|
|
|
|
):
|
2018-05-26 23:19:05 +00:00
|
|
|
'''
|
2019-04-03 05:30:14 +00:00
|
|
|
Given a local or remote repository path, and a storage config dict, display summary information
|
|
|
|
for Borg archives in the repository or return JSON summary information.
|
2018-05-26 23:19:05 +00:00
|
|
|
'''
|
|
|
|
lock_wait = storage_config.get('lock_wait', None)
|
|
|
|
|
|
|
|
full_command = (
|
|
|
|
(local_path, 'info', repository)
|
|
|
|
+ (('--remote-path', remote_path) if remote_path else ())
|
|
|
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
2019-06-11 23:42:04 +00:00
|
|
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO and not json else ())
|
|
|
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) and not json else ())
|
2018-07-29 03:17:45 +00:00
|
|
|
+ (('--json',) if json else ())
|
2018-05-26 23:19:05 +00:00
|
|
|
)
|
|
|
|
|
2019-04-03 05:30:14 +00:00
|
|
|
return execute_command(full_command, capture_output=json)
|