Implement json output for create_archive.

This time correctly, hopyfully.
This commit is contained in:
Florian Lindner 2018-09-30 11:10:39 +02:00
parent 3821636b77
commit c4792aebb0
2 changed files with 8 additions and 2 deletions

View File

@ -157,4 +157,5 @@ def create_archive(
) )
logger.debug(' '.join(full_command)) logger.debug(' '.join(full_command))
subprocess.check_call(full_command) output = subprocess.check_output(full_command)
return output.decode() if output is not None else None

View File

@ -176,14 +176,19 @@ def _run_commands_on_repository(
) )
if args.create: if args.create:
logger.info('{}: Creating archive{}'.format(repository, dry_run_label)) logger.info('{}: Creating archive{}'.format(repository, dry_run_label))
borg_create.create_archive( output = borg_create.create_archive(
args.dry_run, args.dry_run,
repository, repository,
location, location,
storage, storage,
local_path=local_path, local_path=local_path,
remote_path=remote_path, remote_path=remote_path,
json=args.json,
) )
if args.json:
json_results.append(json.loads(output))
else:
sys.stdout.write(output)
if args.check: if args.check:
logger.info('{}: Running consistency checks'.format(repository)) logger.info('{}: Running consistency checks'.format(repository))
borg_check.check_archives( borg_check.check_archives(