1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-11 07:06:16 +01:00

check if stdout is a tty before call pager

Check if stdout is a tty before call pager otherwise simply
print the text out.

Signed-off-by: Danny Kukawka <danny.kukawka@web.de>
This commit is contained in:
Danny Kukawka 2010-05-03 18:04:26 +02:00 committed by Ludwig Nussel
parent 5a19362570
commit 23274b58d4

View File

@ -2481,20 +2481,23 @@ def read_meta_from_spec(specfile, *args):
return spec_data
def run_pager(message):
import tempfile
import tempfile, sys
tmpfile = None
if not sys.stdout.isatty:
print message
else:
tmpfile = None
if tmpfile is None:
tmpfile = tempfile.NamedTemporaryFile()
if tmpfile is None:
tmpfile = tempfile.NamedTemporaryFile()
tmpfile.write(message)
tmpfile.flush()
pager = os.getenv('PAGER', default='less')
subprocess.call('%s %s' % (pager, tmpfile.name), shell=True)
tmpfile.write(message)
tmpfile.flush()
pager = os.getenv('PAGER', default='less')
subprocess.call('%s %s' % (pager, tmpfile.name), shell=True)
if tmpfile is not None:
tmpfile.close()
if tmpfile is not None:
tmpfile.close()
def run_editor(filename):