Bug 1195748 - Fix mach auto-logging on Windows. r=gps

We were relying on the log manager's terminal to know whether we're
running on a terminal to turn on auto-logging, but the log manager's
terminal is always None on Windows because blessings imports curses,
which doesn't work on Windows.

So instead, just use a plain os.isatty() call.

The same problem also applies to the show-log command to trigger the
pager (less). At the same time, fix the environment setting for LESS,
as on Windows, unicode literals are not allowed in the environment.

--HG--
extra : rebase_source : 1462849608c8cb86afcb080184efb50caf6d2f9e
This commit is contained in:
Mike Hommey 2016-07-27 13:42:18 +09:00
Родитель 27dab6f2a1
Коммит 6283835342
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -755,7 +755,7 @@ class MachCommandBase(MozbuildObject):
# Always keep a log of the last command, but don't do that for mach
# invokations from scripts (especially not the ones done by the build
# system itself).
if (self.log_manager and self.log_manager.terminal and
if (os.isatty(sys.stdout.fileno()) and
not getattr(self, 'NO_AUTO_LOG', False)):
self._ensure_state_subdir_exists('.')
logfile = self._get_state_filename('last_log.json')

Просмотреть файл

@ -672,12 +672,12 @@ class Logs(MachCommandBase):
path = self._get_state_filename('last_log.json')
log_file = open(path, 'rb')
if self.log_manager.terminal:
if os.isatty(sys.stdout.fileno()):
env = dict(os.environ)
if 'LESS' not in env:
# Sensible default flags if none have been set in the user
# environment.
env['LESS'] = 'FRX'
env[b'LESS'] = b'FRX'
less = subprocess.Popen(['less'], stdin=subprocess.PIPE, env=env)
# Various objects already have a reference to sys.stdout, so we
# can't just change it, we need to change the file descriptor under