This repository was archived by the owner on Dec 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathsubprocess.py
140 lines (114 loc) · 4.19 KB
/
subprocess.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
"""Skeleton for 'subprocess' stdlib module."""
def call(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None,
preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None,
universal_newlines=False, startupinfo=None, creationflags=0,
timeout=None, restore_signals=True, start_new_session=False,
pass_fds=()):
"""Run the command described by args.
:type args: collections.Iterable[bytes | unicode]
:type bufsize: int
:type executable: bytes | unicode | None
:type close_fds: bool
:type shell: bool
:type cwd: bytes | unicode | None
:type env: collections.Mapping | None
:type universal_newlines: bool
:type creationflags: int
:rtype: int
"""
return 0
def check_call(args, bufsize=0, executable=None, stdin=None, stdout=None,
stderr=None, preexec_fn=None, close_fds=False, shell=False,
cwd=None, env=None, universal_newlines=False, startupinfo=None,
creationflags=0, timeout=None, restore_signals=True,
start_new_session=False, pass_fds=()):
"""Run command with arguments. Wait for command to complete. If the return
code was zero then return, otherwise raise CalledProcessError.
:type args: collections.Iterable[bytes | unicode]
:type bufsize: int
:type executable: bytes | unicode | None
:type close_fds: bool
:type shell: bool
:type cwd: bytes | unicode | None
:type env: collections.Mapping | None
:type universal_newlines: bool
:type creationflags: int
:rtype: int
"""
return 0
def check_output(args, bufsize=0, executable=None, stdin=None, stderr=None,
preexec_fn=None, close_fds=False, shell=False, cwd=None,
env=None, universal_newlines=False, startupinfo=None,
creationflags=0, timeout=None, restore_signals=True,
start_new_session=False, pass_fds=()):
"""Run command with arguments and return its output as a byte string.
:type args: collections.Iterable[bytes | unicode]
:type bufsize: int
:type executable: bytes | unicode | None
:type close_fds: bool
:type shell: bool
:type cwd: bytes | unicode | None
:type env: collections.Mapping | None
:type universal_newlines: bool
:type creationflags: int
:rtype: bytes
"""
pass
class Popen(object):
"""Execute a child program in a new process.
:type returncode: int
"""
def __init__(self, args, bufsize=0, executable=None, stdin=None,
stdout=None, stderr=None, preexec_fn=None, close_fds=False,
shell=False, cwd=None, env=None, universal_newlines=False,
startupinfo=None, creationflags=0, timeout=None,
restore_signals=True, start_new_session=False, pass_fds=()):
"""Popen constructor.
:type args: collections.Iterable[bytes | unicode]
:type bufsize: int
:type executable: bytes | unicode | None
:type close_fds: bool
:type shell: bool
:type cwd: bytes | unicode | None
:type env: collections.Mapping | None
:type universal_newlines: bool
:type creationflags: int
"""
self.stdin = stdin
self.stdout = stdout
self.stderr = stderr
self.pid = 0
self.returncode = 0
def poll(self):
"""Check if child process has terminated.
:rtype: int
"""
return 0
def wait(self, timeout=None):
"""Wait for child process to terminate.
:rtype: int
"""
return 0
def communicate(self, input=None, timeout=None):
"""Interact with process: Send data to stdin. Read data from stdout and
stderr, until end-of-file is reached.
:type input: bytes | unicode | None
:rtype: (bytes, bytes)
"""
return b'', b''
def send_signal(self, signal):
"""Sends the signal signal to the child.
:type signal: int
:rtype: None
"""
pass
def terminate(self):
"""Stop the child.
:rtype: None
"""
pass
def kill(self):
"""Kills the child.
:rtype: None
"""
pass