patman: Drop binary parameter
Since cros_subprocess use bytestrings now, this feature not needed. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
6891152a45
commit
3b1c0b09c9
@ -54,7 +54,7 @@ class Popen(subprocess.Popen):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, args, stdin=None, stdout=PIPE_PTY, stderr=PIPE_PTY,
|
def __init__(self, args, stdin=None, stdout=PIPE_PTY, stderr=PIPE_PTY,
|
||||||
shell=False, cwd=None, env=None, binary=False, **kwargs):
|
shell=False, cwd=None, env=None, **kwargs):
|
||||||
"""Cut-down constructor
|
"""Cut-down constructor
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -72,7 +72,6 @@ class Popen(subprocess.Popen):
|
|||||||
"""
|
"""
|
||||||
stdout_pty = None
|
stdout_pty = None
|
||||||
stderr_pty = None
|
stderr_pty = None
|
||||||
self.binary = binary
|
|
||||||
|
|
||||||
if stdout == PIPE_PTY:
|
if stdout == PIPE_PTY:
|
||||||
stdout_pty = pty.openpty()
|
stdout_pty = pty.openpty()
|
||||||
|
@ -186,7 +186,7 @@ def PathHasFile(path_spec, fname):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def Run(name, *args, **kwargs):
|
def Run(name, *args):
|
||||||
"""Run a tool with some arguments
|
"""Run a tool with some arguments
|
||||||
|
|
||||||
This runs a 'tool', which is a program used by binman to process files and
|
This runs a 'tool', which is a program used by binman to process files and
|
||||||
@ -196,7 +196,6 @@ def Run(name, *args, **kwargs):
|
|||||||
Args:
|
Args:
|
||||||
name: Command name to run
|
name: Command name to run
|
||||||
args: Arguments to the tool
|
args: Arguments to the tool
|
||||||
kwargs: Options to pass to command.run()
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
CommandResult object
|
CommandResult object
|
||||||
@ -206,8 +205,8 @@ def Run(name, *args, **kwargs):
|
|||||||
if tool_search_paths:
|
if tool_search_paths:
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
env['PATH'] = ':'.join(tool_search_paths) + ':' + env['PATH']
|
env['PATH'] = ':'.join(tool_search_paths) + ':' + env['PATH']
|
||||||
return command.Run(name, *args, capture=True,
|
return command.Run(name, *args, capture=True, capture_stderr=True,
|
||||||
capture_stderr=True, env=env, **kwargs)
|
env=env)
|
||||||
except:
|
except:
|
||||||
if env and not PathHasFile(env['PATH'], name):
|
if env and not PathHasFile(env['PATH'], name):
|
||||||
msg = "Please install tool '%s'" % name
|
msg = "Please install tool '%s'" % name
|
||||||
@ -401,14 +400,14 @@ def Compress(indata, algo, with_header=True):
|
|||||||
fname = GetOutputFilename('%s.comp.tmp' % algo)
|
fname = GetOutputFilename('%s.comp.tmp' % algo)
|
||||||
WriteFile(fname, indata)
|
WriteFile(fname, indata)
|
||||||
if algo == 'lz4':
|
if algo == 'lz4':
|
||||||
data = Run('lz4', '--no-frame-crc', '-c', fname, binary=True)
|
data = Run('lz4', '--no-frame-crc', '-c', fname)
|
||||||
# cbfstool uses a very old version of lzma
|
# cbfstool uses a very old version of lzma
|
||||||
elif algo == 'lzma':
|
elif algo == 'lzma':
|
||||||
outfname = GetOutputFilename('%s.comp.otmp' % algo)
|
outfname = GetOutputFilename('%s.comp.otmp' % algo)
|
||||||
Run('lzma_alone', 'e', fname, outfname, '-lc1', '-lp0', '-pb0', '-d8')
|
Run('lzma_alone', 'e', fname, outfname, '-lc1', '-lp0', '-pb0', '-d8')
|
||||||
data = ReadFile(outfname)
|
data = ReadFile(outfname)
|
||||||
elif algo == 'gzip':
|
elif algo == 'gzip':
|
||||||
data = Run('gzip', '-c', fname, binary=True)
|
data = Run('gzip', '-c', fname)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown algorithm '%s'" % algo)
|
raise ValueError("Unknown algorithm '%s'" % algo)
|
||||||
if with_header:
|
if with_header:
|
||||||
@ -441,13 +440,13 @@ def Decompress(indata, algo, with_header=True):
|
|||||||
with open(fname, 'wb') as fd:
|
with open(fname, 'wb') as fd:
|
||||||
fd.write(indata)
|
fd.write(indata)
|
||||||
if algo == 'lz4':
|
if algo == 'lz4':
|
||||||
data = Run('lz4', '-dc', fname, binary=True)
|
data = Run('lz4', '-dc', fname)
|
||||||
elif algo == 'lzma':
|
elif algo == 'lzma':
|
||||||
outfname = GetOutputFilename('%s.decomp.otmp' % algo)
|
outfname = GetOutputFilename('%s.decomp.otmp' % algo)
|
||||||
Run('lzma_alone', 'd', fname, outfname)
|
Run('lzma_alone', 'd', fname, outfname)
|
||||||
data = ReadFile(outfname)
|
data = ReadFile(outfname)
|
||||||
elif algo == 'gzip':
|
elif algo == 'gzip':
|
||||||
data = Run('gzip', '-cd', fname, binary=True)
|
data = Run('gzip', '-cd', fname)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown algorithm '%s'" % algo)
|
raise ValueError("Unknown algorithm '%s'" % algo)
|
||||||
return data
|
return data
|
||||||
|
Loading…
Reference in New Issue
Block a user