From d3271096048afcfefd1afcc28bbbc597e74ab57b Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Mon, 27 Feb 2017 22:36:09 +0100 Subject: [PATCH] json progress: emit info (current $something) --- docs/internals/frontends.rst | 9 ++++++++- src/borg/helpers.py | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/internals/frontends.rst b/docs/internals/frontends.rst index 85b00134d..66ea85843 100644 --- a/docs/internals/frontends.rst +++ b/docs/internals/frontends.rst @@ -22,7 +22,8 @@ where each line is a JSON object. The *type* key of the object determines its ot Since JSON can only encode text, any string representing a file system path may miss non-text parts. -The following types are in use: +The following types are in use. Progress information is governed by the usual rules for progress information, +it is not produced unless ``--progress`` is specified. archive_progress Output during operations creating archives (:ref:`borg_create` and :ref:`borg_recreate`). @@ -67,6 +68,8 @@ progress_percent A formatted progress message, this will include the percentage and perhaps other information current Current value (always less-or-equal to *total*) + info + Array that describes the current item, may be *none*, contents depend on *msgid* total Total value @@ -218,10 +221,14 @@ Operations - cache.begin_transaction - cache.commit - cache.sync + + *info* is one string element, the name of the archive currently synced. - repository.compact_segments - repository.replay_segments - repository.check_segments - check.verify_data - extract + + *info* is one string element, the name of the path currently extracted. - extract.permissions - archive.delete diff --git a/src/borg/helpers.py b/src/borg/helpers.py index b4efd7e70..da6ef776e 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -1508,13 +1508,13 @@ class ProgressIndicatorPercent(ProgressIndicatorBase): if terminal_space != -1: space = terminal_space - len(self.msg % tuple([pct] + info[:-1] + [''])) info[-1] = ellipsis_truncate(info[-1], space) - return self.output(self.msg % tuple([pct] + info), justify=False) + return self.output(self.msg % tuple([pct] + info), justify=False, info=info) return self.output(self.msg % pct) - def output(self, message, justify=True): + def output(self, message, justify=True, info=None): if self.json: - self.output_json(message=message, current=self.counter, total=self.total) + self.output_json(message=message, current=self.counter, total=self.total, info=info) else: if justify: message = justify_to_terminal_size(message)