Create an interactive session and execute the commands passed as "cmds" and return all output :param cmds: a list of commands to run :param timeout: timeout in seconds :returns: (output, returned) contains both sys.stdout and sys.stderr logs
(cmds, **kargs)
| 151 | |
| 152 | |
| 153 | def autorun_get_interactive_session(cmds, **kargs): |
| 154 | # type: (str, **Any) -> Tuple[str, Any] |
| 155 | """Create an interactive session and execute the |
| 156 | commands passed as "cmds" and return all output |
| 157 | |
| 158 | :param cmds: a list of commands to run |
| 159 | :param timeout: timeout in seconds |
| 160 | :returns: (output, returned) contains both sys.stdout and sys.stderr logs |
| 161 | """ |
| 162 | sstdout, sstderr, sexcepthook = sys.stdout, sys.stderr, sys.excepthook |
| 163 | sw = StringWriter() |
| 164 | h_old = log_scapy.handlers[0] |
| 165 | log_scapy.removeHandler(h_old) |
| 166 | log_scapy.addHandler(logging.StreamHandler(stream=sw)) |
| 167 | try: |
| 168 | try: |
| 169 | sys.stdout = sys.stderr = sw |
| 170 | sys.excepthook = sys.__excepthook__ |
| 171 | res = autorun_commands_timeout(cmds, **kargs) |
| 172 | except StopAutorun as e: |
| 173 | e.code_run = sw.s |
| 174 | raise |
| 175 | finally: |
| 176 | sys.stdout, sys.stderr, sys.excepthook = sstdout, sstderr, sexcepthook |
| 177 | log_scapy.removeHandler(log_scapy.handlers[0]) |
| 178 | log_scapy.addHandler(h_old) |
| 179 | return sw.s, res |
| 180 | |
| 181 | |
| 182 | def autorun_get_interactive_live_session(cmds, **kargs): |
no test coverage detected
searching dependent graphs…