Blob Blame History Raw
From d975e802c6513463cc52efa0cfdfaa2d2de84adf Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Thu, 3 Oct 2013 17:57:42 +0100
Subject: [PATCH 1/2] No TTY should not imply batch mode

Commit 6ea48cbb introduced an isatty() check on stdin and
automatically sets batch mode if we're not attached to a TTY.

Although the logic of this seems simple enough the combination of
this and commit 4b46e04 breaks valid uses that have worked since
sos-1.x, e.g.:

Traceback (most recent call last):
  File "/usr/sbin/sosreport", line 23, in <module>
    main(sys.argv[1:])
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1171, in main
    sos.execute()
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1133, in execute
    self._setup_logging()
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 630, in _setup_logging
    self.opts.batch = True
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 324, in batch
    self._check_options_initialized()
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 229, in _check_options_initialized
    + "from command line")
ValueError: SoSOptions object already initialized from command line

Given the actual semantics of --batch (do not prompt for or read
user input from stdin) there is no need to enable it if stdin is
a pipe or other non-TTY file descriptor.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/sosreport.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/sos/sosreport.py b/sos/sosreport.py
index 908cbed..88c6730 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -625,10 +625,6 @@ class SoSReport(object):
             pass
 
     def _setup_logging(self):
-
-        if not sys.stdin.isatty():
-            self.opts.batch = True
-
         # main soslog
         self.soslog = logging.getLogger('sos')
         self.soslog.setLevel(logging.DEBUG)
-- 
1.7.11.7