(self, output)
| 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 |
nothing calls this directly
no test coverage detected