@@ -1262,7 +1262,8 @@ def pfeedback(self, msg):
1262
1262
def ppaged (self , msg , end = '\n ' ):
1263
1263
"""Print output using a pager if it would go off screen and stdout isn't currently being redirected.
1264
1264
1265
- Never uses a pager inside of a script (Python or text) or when output is being redirected or piped.
1265
+ Never uses a pager inside of a script (Python or text) or when output is being redirected or piped or when
1266
+ stdout or stdin are not a fully functional terminal.
1266
1267
1267
1268
:param msg: str - message to print to current stdout - anything convertible to a str with '{}'.format() is OK
1268
1269
:param end: str - string appended after the end of the message if not already present, default a newline
@@ -1273,8 +1274,16 @@ def ppaged(self, msg, end='\n'):
1273
1274
if not msg_str .endswith (end ):
1274
1275
msg_str += end
1275
1276
1277
+ # Attempt to detect if we are not running within a fully functional terminal.
1278
+ # Don't try to use the pager when being run by a continuous integration system like Jenkins + pexpect.
1279
+ functional_terminal = False
1280
+ if self .stdin .isatty () and self .stdout .isatty ():
1281
+ if sys .platform .startswith ('win' ) or os .environ .get ('TERM' ) is not None :
1282
+ functional_terminal = True
1283
+
1276
1284
# Don't attempt to use a pager that can block if redirecting or running a script (either text or Python)
1277
- if not self .redirecting and not self ._in_py and not self ._script_dir :
1285
+ # Also only attempt to use a pager if actually running in a real fully functional terminal
1286
+ if functional_terminal and not self .redirecting and not self ._in_py and not self ._script_dir :
1278
1287
if sys .platform .startswith ('win' ):
1279
1288
pager_cmd = 'more'
1280
1289
else :
0 commit comments