Merge "net_helpers: Set process streams to text mode"
This commit is contained in:
commit
211fb55fab
@ -268,6 +268,8 @@ class RootHelperProcess(subprocess.Popen):
|
|||||||
def __init__(self, cmd, *args, **kwargs):
|
def __init__(self, cmd, *args, **kwargs):
|
||||||
for arg in ('stdin', 'stdout', 'stderr'):
|
for arg in ('stdin', 'stdout', 'stderr'):
|
||||||
kwargs.setdefault(arg, subprocess.PIPE)
|
kwargs.setdefault(arg, subprocess.PIPE)
|
||||||
|
kwargs.setdefault('universal_newlines', True)
|
||||||
|
|
||||||
self.namespace = kwargs.pop('namespace', None)
|
self.namespace = kwargs.pop('namespace', None)
|
||||||
self.cmd = cmd
|
self.cmd = cmd
|
||||||
if self.namespace is not None:
|
if self.namespace is not None:
|
||||||
@ -283,7 +285,7 @@ class RootHelperProcess(subprocess.Popen):
|
|||||||
utils.execute(['kill', '-%d' % sig, pid], run_as_root=True)
|
utils.execute(['kill', '-%d' % sig, pid], run_as_root=True)
|
||||||
|
|
||||||
def read_stdout(self, timeout=None):
|
def read_stdout(self, timeout=None):
|
||||||
return self._read_stream(self.stdout, timeout).decode('utf-8')
|
return self._read_stream(self.stdout, timeout)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _read_stream(stream, timeout):
|
def _read_stream(stream, timeout):
|
||||||
@ -294,7 +296,7 @@ class RootHelperProcess(subprocess.Popen):
|
|||||||
return stream.readline()
|
return stream.readline()
|
||||||
|
|
||||||
def writeline(self, data):
|
def writeline(self, data):
|
||||||
self.stdin.write((data + os.linesep).encode('utf-8'))
|
self.stdin.write(data + os.linesep)
|
||||||
self.stdin.flush()
|
self.stdin.flush()
|
||||||
|
|
||||||
def _wait_for_child_process(self, timeout=CHILD_PROCESS_TIMEOUT,
|
def _wait_for_child_process(self, timeout=CHILD_PROCESS_TIMEOUT,
|
||||||
|
Loading…
Reference in New Issue
Block a user