Merge pull request #405 from erinxocon/vendor-delagator-update

Vendor delagator.py update
This commit is contained in:
Nate Prewitt
2017-06-09 19:26:20 -06:00
committed by GitHub
3 changed files with 22 additions and 11 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
flake8 = ">=3.3.0,<4"
pytest = "*"
mock = "*"
"delegator.py" = ">=0.0.10"
"delegator.py" = ">=0.0.12"
toml = "*"
Sphinx = "<=1.5.5"
+20 -9
View File
@@ -14,11 +14,14 @@ try:
except NameError:
STR_TYPES = (str, )
TIMEOUT = 30
class Command(object):
def __init__(self, cmd):
def __init__(self, cmd, timeout=TIMEOUT):
super(Command, self).__init__()
self.cmd = cmd
self.timeout = timeout
self.subprocess = None
self.blocking = None
self.was_run = False
@@ -48,7 +51,8 @@ class Command(object):
def _default_pexpect_kwargs(self):
return {
'env': os.environ.copy(),
'encoding': 'utf-8'
'encoding': 'utf-8',
'timeout': self.timeout
}
@property
@@ -185,16 +189,23 @@ class Command(object):
else:
self.subprocess.wait()
def pipe(self, command):
def pipe(self, command, timeout=None):
"""Runs the current command and passes its output to the next
given process.
"""
if not timeout:
timeout = self.timeout
if not self.was_run:
self.run(block=False)
data = self.out
c = Command(command)
if timeout:
c = Command(command, timeout)
else:
c = Command(command)
c.run(block=False)
if data:
c.send(data)
@@ -225,13 +236,13 @@ def _expand_args(command):
return command
def chain(command):
def chain(command, timeout=TIMEOUT):
commands = _expand_args(command)
data = None
for command in commands:
c = run(command, block=False)
c = run(command, block=False, timeout=timeout)
if data:
c.send(data)
@@ -242,11 +253,11 @@ def chain(command):
return c
def run(command, block=True, binary=False):
c = Command(command)
def run(command, block=True, binary=False, timeout=TIMEOUT):
c = Command(command, timeout=timeout)
c.run(block=block, binary=binary)
if block:
c.block()
return c
return c
+1 -1
View File
@@ -5,7 +5,7 @@ Babel==2.4.0
backports.shutil-get-terminal-size==1.0.0
certifi==2017.4.17
chardet==3.0.3
delegator.py==0.0.10
delegator.py==0.0.12
docutils==0.13.1
funcsigs==1.0.2
idna==2.5