MCPcopy Index your code
hub / github.com/aws/aws-cli / _send_output_to_pager

Method _send_output_to_pager

awscli/help.py:199–222  ·  view source on GitHub ↗
(self, output)

Source from the content-addressed store, hash-verified

197 PAGER = 'less -R'
198
199 def _send_output_to_pager(self, output):
200 cmdline = self.get_pager_cmdline()
201 if not self._exists_on_path(cmdline[0]):
202 LOG.debug(
203 f"Pager '{cmdline[0]}' not found in PATH, printing raw help."
204 )
205 self.output_stream.write(output.decode('utf-8') + "\n")
206 self.output_stream.flush()
207 return
208 LOG.debug("Running command: %s", cmdline)
209 with ignore_ctrl_c():
210 # We can't rely on the KeyboardInterrupt from
211 # the CLIDriver being caught because when we
212 # send the output to a pager it will use various
213 # control characters that need to be cleaned
214 # up gracefully. Otherwise if we simply catch
215 # the Ctrl-C and exit, it will likely leave the
216 # users terminals in a bad state and they'll need
217 # to manually run ``reset`` to fix this issue.
218 # Ignoring Ctrl-C solves this issue. It's also
219 # the default behavior of less (you can't ctrl-c
220 # out of a manpage).
221 p = self._popen(cmdline, stdin=PIPE)
222 p.communicate(input=output)
223
224 def _exists_on_path(self, name):
225 # Since we're only dealing with POSIX systems, we can

Callers

nothing calls this directly

Calls 8

_exists_on_pathMethod · 0.95
ignore_ctrl_cFunction · 0.90
get_pager_cmdlineMethod · 0.80
decodeMethod · 0.80
writeMethod · 0.45
flushMethod · 0.45
_popenMethod · 0.45
communicateMethod · 0.45

Tested by

no test coverage detected