|
1 | 1 | # -*- coding: utf-8 -*-
|
2 | 2 |
|
3 |
| -import argparse |
4 | 3 | import io
|
5 | 4 |
|
6 | 5 | from .netcat import (
|
|
18 | 17 | readwrite,
|
19 | 18 | )
|
20 | 19 |
|
21 |
| - |
22 |
| -class CompletedNetcat(argparse.Namespace): |
| 20 | + |
| 21 | +class CompletedNetcat(object): |
23 | 22 | """
|
24 |
| - This class gets returned from the :func:`pync.run` function. |
| 23 | + A Netcat instance that has finished running. |
| 24 | + This is returned by the :func:`pync.run` function. |
| 25 | +
|
| 26 | + :param args: The args string given to run the Netcat instance. |
| 27 | + :type args: str |
| 28 | + |
| 29 | + :param returncode: The exit code of the Netcat instance. |
| 30 | + :type returncode: int |
| 31 | +
|
| 32 | + :param stdout: The standard output (None if not captured). |
| 33 | + :type stdout: file, optional |
| 34 | + |
| 35 | + :param stderr: The standard error (None if not captured). |
| 36 | + :type stderr: file, optional |
25 | 37 | """
|
| 38 | + |
| 39 | + def __init__(self, args, returncode, stdout=None, stderr=None): |
| 40 | + self.args = args |
| 41 | + self.returncode = returncode |
| 42 | + self.stdout = stdout |
| 43 | + self.stderr = stderr |
26 | 44 |
|
27 | 45 |
|
28 | 46 | def run(args, stdin=None, stdout=None, stderr=None,
|
@@ -94,14 +112,10 @@ def run(args, stdin=None, stdout=None, stderr=None,
|
94 | 112 | :caption: Connect to a local TCP server and capture output to a byte string.
|
95 | 113 |
|
96 | 114 | import pync
|
97 |
| - response = pync.run('localhost 8000', capture_output=True) |
98 |
| - print(response.stdout.decode()) |
| 115 | + result = pync.run('localhost 8000', capture_output=True) |
| 116 | + print(result.stdout.decode()) |
99 | 117 | """
|
100 |
| - result = CompletedNetcat() |
101 |
| - result.returncode = 1 |
102 |
| - result.args = args |
103 |
| - result.stdout = None |
104 |
| - result.stderr = None |
| 118 | + result = CompletedNetcat(args, returncode=1) |
105 | 119 |
|
106 | 120 | stdin_io = stdin or Netcat.stdin
|
107 | 121 | stdout_io = stdout or Netcat.stdout
|
|
0 commit comments