mirror of https://github.com/flaggo/pydu.git
modify run method
This commit is contained in:
parent
4beaa525d5
commit
f715b37153
|
@ -10,16 +10,14 @@ def run(cmd, wait=True, shell=True, timeout=0, timeinterval=1):
|
||||||
if not wait:
|
if not wait:
|
||||||
return p
|
return p
|
||||||
|
|
||||||
if not timeout:
|
if timeout:
|
||||||
stdout, _ = p.communicate()
|
|
||||||
return p.poll(), stdout
|
|
||||||
|
|
||||||
while timeout > 0 and p.poll() is None:
|
while timeout > 0 and p.poll() is None:
|
||||||
timeout = timeout - timeinterval
|
timeout = timeout - timeinterval
|
||||||
time.sleep(timeinterval)
|
time.sleep(timeinterval)
|
||||||
if p.poll() is None:
|
if p.poll() is None:
|
||||||
p.kill()
|
p.kill()
|
||||||
return p.poll(), 'Run timeout'
|
return p.poll(), 'Run timeout'
|
||||||
|
|
||||||
stdout, _ = p.communicate()
|
stdout, _ = p.communicate()
|
||||||
return p.poll(), stdout
|
return p.poll(), stdout
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue