]> arthur.barton.de Git - bup.git/commitdiff
random: use helpers.istty1
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 30 Nov 2021 20:23:05 +0000 (21:23 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 5 Dec 2021 20:26:53 +0000 (14:26 -0600)
The helpers.istty1 variable can be used in place of the
same conditions open-coded here.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/cmd/random.py

index c4b234ee0933efc89114b7d416cdec9c61bd4425..9ad64e4804e66d2a32c56408a446ab8a7e099f9a 100755 (executable)
@@ -1,9 +1,9 @@
 
 from __future__ import absolute_import
-import os, sys
+import sys
 
 from bup import options, _helpers
-from bup.helpers import handle_ctrl_c, log, parse_num
+from bup.helpers import handle_ctrl_c, log, parse_num, istty1
 
 
 optspec = """
@@ -25,8 +25,7 @@ def main(argv):
 
     handle_ctrl_c()
 
-    if opt.force or (not os.isatty(1) and
-                     not int(os.environ.get('BUP_FORCE_TTY', 0)) & 1):
+    if opt.force or not istty1:
         _helpers.write_random(sys.stdout.fileno(), total, opt.seed,
                               opt.verbose and 1 or 0)
     else: