|
Lines 40-45
Link Here
|
| 40 |
import re |
40 |
import re |
| 41 |
import dns.resolver |
41 |
import dns.resolver |
| 42 |
import dns.exception |
42 |
import dns.exception |
|
|
43 |
import fcntl |
| 44 |
import errno |
| 43 |
|
45 |
|
| 44 |
import notifier.threads |
46 |
import notifier.threads |
| 45 |
import apt_pkg |
47 |
import apt_pkg |
|
Lines 197-209
def run(cmd, stepsPerScript, info_handler = _dummyFunc, error_handler = _dummyFu
Link Here
|
| 197 |
process = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
199 |
process = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 198 |
|
200 |
|
| 199 |
failedJoinScripts = [] |
201 |
failedJoinScripts = [] |
| 200 |
while True: |
202 |
def parse(line): |
| 201 |
# get the next line |
203 |
MODULE.process(repr(line.strip()).strip('"\'')) |
| 202 |
line = process.stdout.readline() |
|
|
| 203 |
if not line: |
| 204 |
# no more text from stdout |
| 205 |
break |
| 206 |
MODULE.process(line.strip()) |
| 207 |
|
204 |
|
| 208 |
# parse output... first check for errors |
205 |
# parse output... first check for errors |
| 209 |
m = regError.match(line) |
206 |
m = regError.match(line) |
|
Lines 234-239
def run(cmd, stepsPerScript, info_handler = _dummyFunc, error_handler = _dummyFu
Link Here
|
| 234 |
step_handler(stepsPerScript/10) |
231 |
step_handler(stepsPerScript/10) |
| 235 |
continue |
232 |
continue |
| 236 |
|
233 |
|
|
|
234 |
# make stdout file descriptor of the process non-blocking |
| 235 |
fd = process.stdout.fileno() |
| 236 |
fl = fcntl.fcntl(fd, fcntl.F_GETFL) |
| 237 |
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) |
| 238 |
|
| 239 |
unfinished_line = '' |
| 240 |
while True: |
| 241 |
# get the next line |
| 242 |
try: |
| 243 |
line = process.stdout.read() |
| 244 |
except IOError as exc: |
| 245 |
if exc.errno == errno.EAGAIN: |
| 246 |
continue |
| 247 |
raise |
| 248 |
|
| 249 |
if not line: |
| 250 |
break # no more text from stdout |
| 251 |
|
| 252 |
unfinished_line = '' if line.endswith('\n') else '%s%s' % (unfinished_line, line.rsplit('\n', 1)[-1]) |
| 253 |
for line in line.splitlines(): |
| 254 |
parse(line) |
| 255 |
if unfinished_line: |
| 256 |
parse(unfinished_line) |
| 257 |
|
| 237 |
# get all remaining output |
258 |
# get all remaining output |
| 238 |
stdout, stderr = process.communicate() |
259 |
stdout, stderr = process.communicate() |
| 239 |
if stderr: |
260 |
if stderr: |