Initiates a :ref:`SysCommandWorker` session in this class ``.session``. It then proceeds to poll the process until it ends, after which it also clears any printed output if ``.peek_output=True``.
(self)
| 272 | return self.decode('UTF-8', errors='backslashreplace') or '' |
| 273 | |
| 274 | def create_session(self) -> bool: |
| 275 | """ |
| 276 | Initiates a :ref:`SysCommandWorker` session in this class ``.session``. |
| 277 | It then proceeds to poll the process until it ends, after which it also |
| 278 | clears any printed output if ``.peek_output=True``. |
| 279 | """ |
| 280 | if self.session: |
| 281 | return True |
| 282 | |
| 283 | with SysCommandWorker( |
| 284 | self.cmd, |
| 285 | peek_output=self.peek_output, |
| 286 | environment_vars=self.environment_vars, |
| 287 | remove_vt100_escape_codes_from_lines=self.remove_vt100_escape_codes_from_lines, |
| 288 | working_directory=self.working_directory, |
| 289 | ) as session: |
| 290 | self.session = session |
| 291 | |
| 292 | while not self.session.ended: |
| 293 | self.session.poll() |
| 294 | |
| 295 | if self.peek_output: |
| 296 | sys.stdout.write('\n') |
| 297 | sys.stdout.flush() |
| 298 | |
| 299 | return True |
| 300 | |
| 301 | def decode(self, encoding: str = 'utf-8', errors: str = 'backslashreplace', strip: bool = True) -> str: |
| 302 | if not self.session: |
no test coverage detected