borgmatic/borgmatic/borg/info.py

25 lines
819 B
Python
Raw Normal View History

import logging
import subprocess
logger = logging.getLogger(__name__)
def display_archives_info(repository, storage_config, local_path='borg', remote_path=None):
'''
Given a verbosity flag, a local or remote repository path, and a storage config dict,
display summary information for Borg archives in the repository.
'''
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 ())
+ (('--info',) if logger.isEnabledFor(logging.INFO) else ())
+ (('--debug',) if logger.isEnabledFor(logging.DEBUG) else ())
)
logger.debug(' '.join(full_command))
subprocess.check_call(full_command)