[PATCH] honor -q flag for bup split

2 views
Skip to first unread message

Brian minton

unread,
Nov 23, 2021, 11:46:38 AM11/23/21
to bup-...@googlegroups.com, Brian Minton
From: Brian Minton <br...@minton.name>

Signed-off-by: Brian Minton <br...@minton.name>
---
lib/bup/cmd/split.py | 14 ++++++++------
test/ext/test-split-join | 8 ++++++++
2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/lib/bup/cmd/split.py b/lib/bup/cmd/split.py
index 11392e2..789266a 100755
--- a/lib/bup/cmd/split.py
+++ b/lib/bup/cmd/split.py
@@ -86,11 +86,12 @@ def main(argv):
total_bytes = [0]
def prog(filenum, nbytes):
total_bytes[0] += nbytes
- if filenum > 0:
- qprogress('Splitting: file #%d, %d kbytes\r'
- % (filenum+1, total_bytes[0] // 1024))
- else:
- qprogress('Splitting: %d kbytes\r' % (total_bytes[0] // 1024))
+ if not opt.quiet:
+ if filenum > 0:
+ qprogress('Splitting: file #%d, %d kbytes\r'
+ % (filenum+1, total_bytes[0] // 1024))
+ else:
+ qprogress('Splitting: %d kbytes\r' % (total_bytes[0] // 1024))


is_reverse = environ.get(b'BUP_SERVER_REVERSE')
@@ -173,7 +174,8 @@ def main(argv):
progress=prog)
for (sha, size, level) in shalist:
out.write(hexlify(sha) + b'\n')
- reprogress()
+ if not opt.quiet:
+ reprogress()
elif opt.tree or opt.commit or opt.name:
if opt.name: # insert dummy_name which may be used as a restore target
mode, sha = \
diff --git a/test/ext/test-split-join b/test/ext/test-split-join
index 548f110..b68e344 100755
--- a/test/ext/test-split-join
+++ b/test/ext/test-split-join
@@ -22,6 +22,14 @@ WVPASS bup split --noop -b <"$top/test/testfile1" >tags1n.tmp
WVPASS bup split --noop -t <"$top/test/testfile2" >tags2tn.tmp
WVPASSEQ $(find "$BUP_DIR/objects/pack" -name '*.pack' | wc -l) 0

+WVSTART "split -q"
+WVPASS script -q -c "bup split -q -b <$top/test/testfile1 >tagsq.tmp" q.tmp
+WVPASS cp q.tmp /tmp
+WVPASS script -q -c "bup split -q -n quiet <$top/test/testfile1" q2.tmp
+WVPASS cp q2.tmp /tmp
+WVFAIL grep -q Splitting q.tmp
+WVFAIL grep -q Splitting q2.tmp
+
WVSTART "split"
WVPASS echo a >a.tmp
WVPASS echo b >b.tmp
--
2.30.2

Rob Browning

unread,
Nov 24, 2021, 2:11:33 PM11/24/21
to Brian minton, bup-...@googlegroups.com, Brian Minton
Brian minton <br...@minton.name> writes:

> + if not opt.quiet:
> + if filenum > 0:
> + qprogress('Splitting: file #%d, %d kbytes\r'
> + % (filenum+1, total_bytes[0] // 1024))
> + else:
> + qprogress('Splitting: %d kbytes\r' % (total_bytes[0] // 1024))

What do you think about changing this to do something like what my patch
did, i.e. just defining two different versions of prog, e.g.:

if opt.quiet:
def prog(...):
pass
else:
...

Likely not a big deal either way; just avoids having to check every call.

> +WVSTART "split -q"
> +WVPASS script -q -c "bup split -q -b <$top/test/testfile1 >tagsq.tmp" q.tmp
> +WVPASS cp q.tmp /tmp
> +WVPASS script -q -c "bup split -q -n quiet <$top/test/testfile1" q2.tmp
> +WVPASS cp q2.tmp /tmp
> +WVFAIL grep -q Splitting q.tmp
> +WVFAIL grep -q Splitting q2.tmp

Hmm, how about something like this:

WVPASS bup split -q -b < "$top/test/testfile1" > tagsq.tmp 2>&1
WVFAIL grep -q Splitting tagsq.tmp
...

To avoid depending on script.

Thanks
--
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4

Brian Minton

unread,
Dec 9, 2021, 9:04:00 AM12/9/21
to Rob Browning, bup-...@googlegroups.com
On 11/24/21 2:11 PM, Rob Browning wrote:
> Brian minton <br...@minton.name> writes:
>
>> + if not opt.quiet:
>> + if filenum > 0:
>> + qprogress('Splitting: file #%d, %d kbytes\r'
>> + % (filenum+1, total_bytes[0] // 1024))
>> + else:
>> + qprogress('Splitting: %d kbytes\r' % (total_bytes[0] // 1024))
>
> What do you think about changing this to do something like what my patch
> did, i.e. just defining two different versions of prog, e.g.:
>

I just wasn't sure if prog was used elsewhere.


> if opt.quiet:
> def prog(...):
> pass
> else:
> ...
>
> Likely not a big deal either way; just avoids having to check every call.

That sounds good to me.

>
>> +WVSTART "split -q"
>> +WVPASS script -q -c "bup split -q -b <$top/test/testfile1 >tagsq.tmp" q.tmp
>> +WVPASS cp q.tmp /tmp
>> +WVPASS script -q -c "bup split -q -n quiet <$top/test/testfile1" q2.tmp
>> +WVPASS cp q2.tmp /tmp
>> +WVFAIL grep -q Splitting q.tmp
>> +WVFAIL grep -q Splitting q2.tmp
>
> Hmm, how about something like this:
>
> WVPASS bup split -q -b < "$top/test/testfile1" > tagsq.tmp 2>&1
> WVFAIL grep -q Splitting tagsq.tmp
> ...
>
> To avoid depending on script.
>
> Thanks
>


I used script because the behavior of bup split is different depending
on if the output is a tty or not. It may be doable with something like
nohup or at. Or, perhaps with python subprocess.
OpenPGP_0x0424DC19B678A1A9.asc
OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages