patman: Convert camel case in command.py
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c1aa66e75d
commit
d98006997c
@ -268,7 +268,7 @@ class Bintool:
|
|||||||
all_args = (name,) + args
|
all_args = (name,) + args
|
||||||
env = tools.get_env_with_path()
|
env = tools.get_env_with_path()
|
||||||
tout.Detail(f"bintool: {' '.join(all_args)}")
|
tout.Detail(f"bintool: {' '.join(all_args)}")
|
||||||
result = command.RunPipe(
|
result = command.run_pipe(
|
||||||
[all_args], capture=True, capture_stderr=True, env=env,
|
[all_args], capture=True, capture_stderr=True, env=env,
|
||||||
raise_on_error=False, binary=binary)
|
raise_on_error=False, binary=binary)
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ SECTIONS
|
|||||||
cc, args = tools.get_target_compile_tool('cc')
|
cc, args = tools.get_target_compile_tool('cc')
|
||||||
args += ['-static', '-nostdlib', '-Wl,--build-id=none', '-m32', '-T',
|
args += ['-static', '-nostdlib', '-Wl,--build-id=none', '-m32', '-T',
|
||||||
lds_file, '-o', elf_fname, s_file]
|
lds_file, '-o', elf_fname, s_file]
|
||||||
stdout = command.Output(cc, *args)
|
stdout = command.output(cc, *args)
|
||||||
shutil.rmtree(outdir)
|
shutil.rmtree(outdir)
|
||||||
|
|
||||||
def DecodeElf(data, location):
|
def DecodeElf(data, location):
|
||||||
|
@ -195,7 +195,7 @@ class TestElf(unittest.TestCase):
|
|||||||
elf.MakeElf(elf_fname, expected_text, expected_data)
|
elf.MakeElf(elf_fname, expected_text, expected_data)
|
||||||
objcopy, args = tools.get_target_compile_tool('objcopy')
|
objcopy, args = tools.get_target_compile_tool('objcopy')
|
||||||
args += ['-O', 'binary', elf_fname, bin_fname]
|
args += ['-O', 'binary', elf_fname, bin_fname]
|
||||||
stdout = command.Output(objcopy, *args)
|
stdout = command.output(objcopy, *args)
|
||||||
with open(bin_fname, 'rb') as fd:
|
with open(bin_fname, 'rb') as fd:
|
||||||
data = fd.read()
|
data = fd.read()
|
||||||
self.assertEqual(expected_text + expected_data, data)
|
self.assertEqual(expected_text + expected_data, data)
|
||||||
|
@ -282,7 +282,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
Arguments to pass, as a list of strings
|
Arguments to pass, as a list of strings
|
||||||
kwargs: Arguments to pass to Command.RunPipe()
|
kwargs: Arguments to pass to Command.RunPipe()
|
||||||
"""
|
"""
|
||||||
result = command.RunPipe([[self._binman_pathname] + list(args)],
|
result = command.run_pipe([[self._binman_pathname] + list(args)],
|
||||||
capture=True, capture_stderr=True, raise_on_error=False)
|
capture=True, capture_stderr=True, raise_on_error=False)
|
||||||
if result.return_code and kwargs.get('raise_on_error', True):
|
if result.return_code and kwargs.get('raise_on_error', True):
|
||||||
raise Exception("Error running '%s': %s" % (' '.join(args),
|
raise Exception("Error running '%s': %s" % (' '.join(args),
|
||||||
|
@ -453,7 +453,7 @@ class Builder:
|
|||||||
stage: Stage that we are at (mrproper, config, build)
|
stage: Stage that we are at (mrproper, config, build)
|
||||||
cwd: Directory where make should be run
|
cwd: Directory where make should be run
|
||||||
args: Arguments to pass to make
|
args: Arguments to pass to make
|
||||||
kwargs: Arguments to pass to command.RunPipe()
|
kwargs: Arguments to pass to command.run_pipe()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def check_output(stream, data):
|
def check_output(stream, data):
|
||||||
@ -476,7 +476,7 @@ class Builder:
|
|||||||
self._restarting_config = False
|
self._restarting_config = False
|
||||||
self._terminated = False
|
self._terminated = False
|
||||||
cmd = [self.gnu_make] + list(args)
|
cmd = [self.gnu_make] + list(args)
|
||||||
result = command.RunPipe([cmd], capture=True, capture_stderr=True,
|
result = command.run_pipe([cmd], capture=True, capture_stderr=True,
|
||||||
cwd=cwd, raise_on_error=False, infile='/dev/null',
|
cwd=cwd, raise_on_error=False, infile='/dev/null',
|
||||||
output_func=check_output, **kwargs)
|
output_func=check_output, **kwargs)
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ class BuilderThread(threading.Thread):
|
|||||||
config - called to configure for a board
|
config - called to configure for a board
|
||||||
build - the main make invocation - it does the build
|
build - the main make invocation - it does the build
|
||||||
args: A list of arguments to pass to 'make'
|
args: A list of arguments to pass to 'make'
|
||||||
kwargs: A list of keyword arguments to pass to command.RunPipe()
|
kwargs: A list of keyword arguments to pass to command.run_pipe()
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
CommandResult object
|
CommandResult object
|
||||||
@ -375,7 +375,7 @@ class BuilderThread(threading.Thread):
|
|||||||
lines = []
|
lines = []
|
||||||
for fname in BASE_ELF_FILENAMES:
|
for fname in BASE_ELF_FILENAMES:
|
||||||
cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname]
|
cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname]
|
||||||
nm_result = command.RunPipe([cmd], capture=True,
|
nm_result = command.run_pipe([cmd], capture=True,
|
||||||
capture_stderr=True, cwd=result.out_dir,
|
capture_stderr=True, cwd=result.out_dir,
|
||||||
raise_on_error=False, env=env)
|
raise_on_error=False, env=env)
|
||||||
if nm_result.stdout:
|
if nm_result.stdout:
|
||||||
@ -385,7 +385,7 @@ class BuilderThread(threading.Thread):
|
|||||||
print(nm_result.stdout, end=' ', file=fd)
|
print(nm_result.stdout, end=' ', file=fd)
|
||||||
|
|
||||||
cmd = ['%sobjdump' % self.toolchain.cross, '-h', fname]
|
cmd = ['%sobjdump' % self.toolchain.cross, '-h', fname]
|
||||||
dump_result = command.RunPipe([cmd], capture=True,
|
dump_result = command.run_pipe([cmd], capture=True,
|
||||||
capture_stderr=True, cwd=result.out_dir,
|
capture_stderr=True, cwd=result.out_dir,
|
||||||
raise_on_error=False, env=env)
|
raise_on_error=False, env=env)
|
||||||
rodata_size = ''
|
rodata_size = ''
|
||||||
@ -400,7 +400,7 @@ class BuilderThread(threading.Thread):
|
|||||||
rodata_size = fields[2]
|
rodata_size = fields[2]
|
||||||
|
|
||||||
cmd = ['%ssize' % self.toolchain.cross, fname]
|
cmd = ['%ssize' % self.toolchain.cross, fname]
|
||||||
size_result = command.RunPipe([cmd], capture=True,
|
size_result = command.run_pipe([cmd], capture=True,
|
||||||
capture_stderr=True, cwd=result.out_dir,
|
capture_stderr=True, cwd=result.out_dir,
|
||||||
raise_on_error=False, env=env)
|
raise_on_error=False, env=env)
|
||||||
if size_result.stdout:
|
if size_result.stdout:
|
||||||
@ -411,7 +411,7 @@ class BuilderThread(threading.Thread):
|
|||||||
cmd = ['%sobjcopy' % self.toolchain.cross, '-O', 'binary',
|
cmd = ['%sobjcopy' % self.toolchain.cross, '-O', 'binary',
|
||||||
'-j', '.rodata.default_environment',
|
'-j', '.rodata.default_environment',
|
||||||
'env/built-in.o', 'uboot.env']
|
'env/built-in.o', 'uboot.env']
|
||||||
command.RunPipe([cmd], capture=True,
|
command.run_pipe([cmd], capture=True,
|
||||||
capture_stderr=True, cwd=result.out_dir,
|
capture_stderr=True, cwd=result.out_dir,
|
||||||
raise_on_error=False, env=env)
|
raise_on_error=False, env=env)
|
||||||
ubootenv = os.path.join(result.out_dir, 'uboot.env')
|
ubootenv = os.path.join(result.out_dir, 'uboot.env')
|
||||||
|
@ -307,7 +307,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
|
|||||||
if not options.step:
|
if not options.step:
|
||||||
options.step = len(series.commits) - 1
|
options.step = len(series.commits) - 1
|
||||||
|
|
||||||
gnu_make = command.Output(os.path.join(options.git,
|
gnu_make = command.output(os.path.join(options.git,
|
||||||
'scripts/show-gnu-make'), raise_on_error=False).rstrip()
|
'scripts/show-gnu-make'), raise_on_error=False).rstrip()
|
||||||
if not gnu_make:
|
if not gnu_make:
|
||||||
sys.exit('GNU Make not found')
|
sys.exit('GNU Make not found')
|
||||||
|
@ -217,7 +217,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
self._toolchains.Add('gcc', test=False)
|
self._toolchains.Add('gcc', test=False)
|
||||||
|
|
||||||
def _RunBuildman(self, *args):
|
def _RunBuildman(self, *args):
|
||||||
return command.RunPipe([[self._buildman_pathname] + list(args)],
|
return command.run_pipe([[self._buildman_pathname] + list(args)],
|
||||||
capture=True, capture_stderr=True)
|
capture=True, capture_stderr=True)
|
||||||
|
|
||||||
def _RunControl(self, *args, boards=None, clean_dir=False,
|
def _RunControl(self, *args, boards=None, clean_dir=False,
|
||||||
@ -407,7 +407,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
stage: Stage that we are at (mrproper, config, build)
|
stage: Stage that we are at (mrproper, config, build)
|
||||||
cwd: Directory where make should be run
|
cwd: Directory where make should be run
|
||||||
args: Arguments to pass to make
|
args: Arguments to pass to make
|
||||||
kwargs: Arguments to pass to command.RunPipe()
|
kwargs: Arguments to pass to command.run_pipe()
|
||||||
"""
|
"""
|
||||||
self._make_calls += 1
|
self._make_calls += 1
|
||||||
if stage == 'mrproper':
|
if stage == 'mrproper':
|
||||||
|
@ -99,7 +99,7 @@ class Toolchain:
|
|||||||
else:
|
else:
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
if test:
|
if test:
|
||||||
result = command.RunPipe([cmd], capture=True, env=env,
|
result = command.run_pipe([cmd], capture=True, env=env,
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
self.ok = result.return_code == 0
|
self.ok = result.return_code == 0
|
||||||
if verbose:
|
if verbose:
|
||||||
@ -494,7 +494,7 @@ class Toolchains:
|
|||||||
else
|
else
|
||||||
URL containing this toolchain, if avaialble, else None
|
URL containing this toolchain, if avaialble, else None
|
||||||
"""
|
"""
|
||||||
arch = command.OutputOneLine('uname', '-m')
|
arch = command.output_one_line('uname', '-m')
|
||||||
if arch == 'aarch64':
|
if arch == 'aarch64':
|
||||||
arch = 'arm64'
|
arch = 'arm64'
|
||||||
base = 'https://www.kernel.org/pub/tools/crosstool/files/bin'
|
base = 'https://www.kernel.org/pub/tools/crosstool/files/bin'
|
||||||
@ -525,7 +525,7 @@ class Toolchains:
|
|||||||
Directory name of the first entry in the archive, without the
|
Directory name of the first entry in the archive, without the
|
||||||
trailing /
|
trailing /
|
||||||
"""
|
"""
|
||||||
stdout = command.Output('tar', 'xvfJ', fname, '-C', dest)
|
stdout = command.output('tar', 'xvfJ', fname, '-C', dest)
|
||||||
dirs = stdout.splitlines()[1].split('/')[:2]
|
dirs = stdout.splitlines()[1].split('/')[:2]
|
||||||
return '/'.join(dirs)
|
return '/'.join(dirs)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False):
|
|||||||
for path in search_paths:
|
for path in search_paths:
|
||||||
args.extend(['-I', path])
|
args.extend(['-I', path])
|
||||||
args += ['-o', dts_input, fname]
|
args += ['-o', dts_input, fname]
|
||||||
command.Run(cc, *args)
|
command.run(cc, *args)
|
||||||
|
|
||||||
# If we don't have a directory, put it in the tools tempdir
|
# If we don't have a directory, put it in the tools tempdir
|
||||||
search_list = []
|
search_list = []
|
||||||
@ -97,7 +97,7 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False):
|
|||||||
'-W', 'no-unit_address_vs_reg']
|
'-W', 'no-unit_address_vs_reg']
|
||||||
args.extend(search_list)
|
args.extend(search_list)
|
||||||
args.append(dts_input)
|
args.append(dts_input)
|
||||||
command.Run(dtc, *args, capture_stderr=capture_stderr)
|
command.run(dtc, *args, capture_stderr=capture_stderr)
|
||||||
return dtb_output
|
return dtb_output
|
||||||
|
|
||||||
def GetInt(node, propname, default=None):
|
def GetInt(node, propname, default=None):
|
||||||
|
@ -213,7 +213,7 @@ def CheckPatch(fname, verbose=False, show_types=False):
|
|||||||
args = [chk, '--no-tree']
|
args = [chk, '--no-tree']
|
||||||
if show_types:
|
if show_types:
|
||||||
args.append('--show-types')
|
args.append('--show-types')
|
||||||
output = command.Output(*args, fname, raise_on_error=False)
|
output = command.output(*args, fname, raise_on_error=False)
|
||||||
|
|
||||||
return CheckPatchParse(output, verbose)
|
return CheckPatchParse(output, verbose)
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class CommandResult:
|
|||||||
self.return_code = return_code
|
self.return_code = return_code
|
||||||
self.exception = exception
|
self.exception = exception
|
||||||
|
|
||||||
def ToOutput(self, binary):
|
def to_output(self, binary):
|
||||||
if not binary:
|
if not binary:
|
||||||
self.stdout = self.stdout.decode('utf-8')
|
self.stdout = self.stdout.decode('utf-8')
|
||||||
self.stderr = self.stderr.decode('utf-8')
|
self.stderr = self.stderr.decode('utf-8')
|
||||||
@ -43,11 +43,11 @@ class CommandResult:
|
|||||||
# This permits interception of RunPipe for test purposes. If it is set to
|
# This permits interception of RunPipe for test purposes. If it is set to
|
||||||
# a function, then that function is called with the pipe list being
|
# a function, then that function is called with the pipe list being
|
||||||
# executed. Otherwise, it is assumed to be a CommandResult object, and is
|
# executed. Otherwise, it is assumed to be a CommandResult object, and is
|
||||||
# returned as the result for every RunPipe() call.
|
# returned as the result for every run_pipe() call.
|
||||||
# When this value is None, commands are executed as normal.
|
# When this value is None, commands are executed as normal.
|
||||||
test_result = None
|
test_result = None
|
||||||
|
|
||||||
def RunPipe(pipe_list, infile=None, outfile=None,
|
def run_pipe(pipe_list, infile=None, outfile=None,
|
||||||
capture=False, capture_stderr=False, oneline=False,
|
capture=False, capture_stderr=False, oneline=False,
|
||||||
raise_on_error=True, cwd=None, binary=False,
|
raise_on_error=True, cwd=None, binary=False,
|
||||||
output_func=None, **kwargs):
|
output_func=None, **kwargs):
|
||||||
@ -104,7 +104,7 @@ def RunPipe(pipe_list, infile=None, outfile=None,
|
|||||||
if raise_on_error:
|
if raise_on_error:
|
||||||
raise Exception("Error running '%s': %s" % (user_pipestr, str))
|
raise Exception("Error running '%s': %s" % (user_pipestr, str))
|
||||||
result.return_code = 255
|
result.return_code = 255
|
||||||
return result.ToOutput(binary)
|
return result.to_output(binary)
|
||||||
|
|
||||||
if capture:
|
if capture:
|
||||||
result.stdout, result.stderr, result.combined = (
|
result.stdout, result.stderr, result.combined = (
|
||||||
@ -116,13 +116,13 @@ def RunPipe(pipe_list, infile=None, outfile=None,
|
|||||||
result.return_code = os.waitpid(last_pipe.pid, 0)[1]
|
result.return_code = os.waitpid(last_pipe.pid, 0)[1]
|
||||||
if raise_on_error and result.return_code:
|
if raise_on_error and result.return_code:
|
||||||
raise Exception("Error running '%s'" % user_pipestr)
|
raise Exception("Error running '%s'" % user_pipestr)
|
||||||
return result.ToOutput(binary)
|
return result.to_output(binary)
|
||||||
|
|
||||||
def Output(*cmd, **kwargs):
|
def output(*cmd, **kwargs):
|
||||||
kwargs['raise_on_error'] = kwargs.get('raise_on_error', True)
|
kwargs['raise_on_error'] = kwargs.get('raise_on_error', True)
|
||||||
return RunPipe([cmd], capture=True, **kwargs).stdout
|
return run_pipe([cmd], capture=True, **kwargs).stdout
|
||||||
|
|
||||||
def OutputOneLine(*cmd, **kwargs):
|
def output_one_line(*cmd, **kwargs):
|
||||||
"""Run a command and output it as a single-line string
|
"""Run a command and output it as a single-line string
|
||||||
|
|
||||||
The command us expected to produce a single line of output
|
The command us expected to produce a single line of output
|
||||||
@ -131,15 +131,15 @@ def OutputOneLine(*cmd, **kwargs):
|
|||||||
String containing output of command
|
String containing output of command
|
||||||
"""
|
"""
|
||||||
raise_on_error = kwargs.pop('raise_on_error', True)
|
raise_on_error = kwargs.pop('raise_on_error', True)
|
||||||
result = RunPipe([cmd], capture=True, oneline=True,
|
result = run_pipe([cmd], capture=True, oneline=True,
|
||||||
raise_on_error=raise_on_error, **kwargs).stdout.strip()
|
raise_on_error=raise_on_error, **kwargs).stdout.strip()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def Run(*cmd, **kwargs):
|
def run(*cmd, **kwargs):
|
||||||
return RunPipe([cmd], **kwargs).stdout
|
return run_pipe([cmd], **kwargs).stdout
|
||||||
|
|
||||||
def RunList(cmd):
|
def run_list(cmd):
|
||||||
return RunPipe([cmd], capture=True).stdout
|
return run_pipe([cmd], capture=True).stdout
|
||||||
|
|
||||||
def StopAll():
|
def stop_all():
|
||||||
cros_subprocess.stay_alive = False
|
cros_subprocess.stay_alive = False
|
||||||
|
@ -43,6 +43,6 @@ def GetMaintainer(dir_list, fname, verbose=False):
|
|||||||
print("WARNING: Couldn't find get_maintainer.pl")
|
print("WARNING: Couldn't find get_maintainer.pl")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
stdout = command.Output(get_maintainer, '--norolestats', fname)
|
stdout = command.output(get_maintainer, '--norolestats', fname)
|
||||||
lines = stdout.splitlines()
|
lines = stdout.splitlines()
|
||||||
return [ x.replace('"', '') for x in lines ]
|
return [ x.replace('"', '') for x in lines ]
|
||||||
|
@ -67,7 +67,7 @@ def CountCommitsToBranch(branch):
|
|||||||
else:
|
else:
|
||||||
rev_range = '@{upstream}..'
|
rev_range = '@{upstream}..'
|
||||||
pipe = [LogCmd(rev_range, oneline=True)]
|
pipe = [LogCmd(rev_range, oneline=True)]
|
||||||
result = command.RunPipe(pipe, capture=True, capture_stderr=True,
|
result = command.run_pipe(pipe, capture=True, capture_stderr=True,
|
||||||
oneline=True, raise_on_error=False)
|
oneline=True, raise_on_error=False)
|
||||||
if result.return_code:
|
if result.return_code:
|
||||||
raise ValueError('Failed to determine upstream: %s' %
|
raise ValueError('Failed to determine upstream: %s' %
|
||||||
@ -85,7 +85,7 @@ def NameRevision(commit_hash):
|
|||||||
Name of revision, if any, else None
|
Name of revision, if any, else None
|
||||||
"""
|
"""
|
||||||
pipe = ['git', 'name-rev', commit_hash]
|
pipe = ['git', 'name-rev', commit_hash]
|
||||||
stdout = command.RunPipe([pipe], capture=True, oneline=True).stdout
|
stdout = command.run_pipe([pipe], capture=True, oneline=True).stdout
|
||||||
|
|
||||||
# We expect a commit, a space, then a revision name
|
# We expect a commit, a space, then a revision name
|
||||||
name = stdout.split(' ')[1].strip()
|
name = stdout.split(' ')[1].strip()
|
||||||
@ -108,7 +108,7 @@ def GuessUpstream(git_dir, branch):
|
|||||||
Warning/error message, or None if none
|
Warning/error message, or None if none
|
||||||
"""
|
"""
|
||||||
pipe = [LogCmd(branch, git_dir=git_dir, oneline=True, count=100)]
|
pipe = [LogCmd(branch, git_dir=git_dir, oneline=True, count=100)]
|
||||||
result = command.RunPipe(pipe, capture=True, capture_stderr=True,
|
result = command.run_pipe(pipe, capture=True, capture_stderr=True,
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
if result.return_code:
|
if result.return_code:
|
||||||
return None, "Branch '%s' not found" % branch
|
return None, "Branch '%s' not found" % branch
|
||||||
@ -134,9 +134,9 @@ def GetUpstream(git_dir, branch):
|
|||||||
Warning/error message, or None if none
|
Warning/error message, or None if none
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
|
remote = command.output_one_line('git', '--git-dir', git_dir, 'config',
|
||||||
'branch.%s.remote' % branch)
|
'branch.%s.remote' % branch)
|
||||||
merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
|
merge = command.output_one_line('git', '--git-dir', git_dir, 'config',
|
||||||
'branch.%s.merge' % branch)
|
'branch.%s.merge' % branch)
|
||||||
except:
|
except:
|
||||||
upstream, msg = GuessUpstream(git_dir, branch)
|
upstream, msg = GuessUpstream(git_dir, branch)
|
||||||
@ -179,7 +179,7 @@ def CountCommitsInRange(git_dir, range_expr):
|
|||||||
were found
|
were found
|
||||||
"""
|
"""
|
||||||
pipe = [LogCmd(range_expr, git_dir=git_dir, oneline=True)]
|
pipe = [LogCmd(range_expr, git_dir=git_dir, oneline=True)]
|
||||||
result = command.RunPipe(pipe, capture=True, capture_stderr=True,
|
result = command.run_pipe(pipe, capture=True, capture_stderr=True,
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
if result.return_code:
|
if result.return_code:
|
||||||
return None, "Range '%s' not found or is invalid" % range_expr
|
return None, "Range '%s' not found or is invalid" % range_expr
|
||||||
@ -211,7 +211,7 @@ def CountCommits(commit_range):
|
|||||||
"""
|
"""
|
||||||
pipe = [LogCmd(commit_range, oneline=True),
|
pipe = [LogCmd(commit_range, oneline=True),
|
||||||
['wc', '-l']]
|
['wc', '-l']]
|
||||||
stdout = command.RunPipe(pipe, capture=True, oneline=True).stdout
|
stdout = command.run_pipe(pipe, capture=True, oneline=True).stdout
|
||||||
patch_count = int(stdout)
|
patch_count = int(stdout)
|
||||||
return patch_count
|
return patch_count
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ def Checkout(commit_hash, git_dir=None, work_tree=None, force=False):
|
|||||||
if force:
|
if force:
|
||||||
pipe.append('-f')
|
pipe.append('-f')
|
||||||
pipe.append(commit_hash)
|
pipe.append(commit_hash)
|
||||||
result = command.RunPipe([pipe], capture=True, raise_on_error=False,
|
result = command.run_pipe([pipe], capture=True, raise_on_error=False,
|
||||||
capture_stderr=True)
|
capture_stderr=True)
|
||||||
if result.return_code != 0:
|
if result.return_code != 0:
|
||||||
raise OSError('git checkout (%s): %s' % (pipe, result.stderr))
|
raise OSError('git checkout (%s): %s' % (pipe, result.stderr))
|
||||||
@ -242,7 +242,7 @@ def Clone(git_dir, output_dir):
|
|||||||
commit_hash: Commit hash to check out
|
commit_hash: Commit hash to check out
|
||||||
"""
|
"""
|
||||||
pipe = ['git', 'clone', git_dir, '.']
|
pipe = ['git', 'clone', git_dir, '.']
|
||||||
result = command.RunPipe([pipe], capture=True, cwd=output_dir,
|
result = command.run_pipe([pipe], capture=True, cwd=output_dir,
|
||||||
capture_stderr=True)
|
capture_stderr=True)
|
||||||
if result.return_code != 0:
|
if result.return_code != 0:
|
||||||
raise OSError('git clone: %s' % result.stderr)
|
raise OSError('git clone: %s' % result.stderr)
|
||||||
@ -259,7 +259,7 @@ def Fetch(git_dir=None, work_tree=None):
|
|||||||
if work_tree:
|
if work_tree:
|
||||||
pipe.extend(['--work-tree', work_tree])
|
pipe.extend(['--work-tree', work_tree])
|
||||||
pipe.append('fetch')
|
pipe.append('fetch')
|
||||||
result = command.RunPipe([pipe], capture=True, capture_stderr=True)
|
result = command.run_pipe([pipe], capture=True, capture_stderr=True)
|
||||||
if result.return_code != 0:
|
if result.return_code != 0:
|
||||||
raise OSError('git fetch: %s' % result.stderr)
|
raise OSError('git fetch: %s' % result.stderr)
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ def CheckWorktreeIsAvailable(git_dir):
|
|||||||
True if git-worktree commands will work, False otherwise.
|
True if git-worktree commands will work, False otherwise.
|
||||||
"""
|
"""
|
||||||
pipe = ['git', '--git-dir', git_dir, 'worktree', 'list']
|
pipe = ['git', '--git-dir', git_dir, 'worktree', 'list']
|
||||||
result = command.RunPipe([pipe], capture=True, capture_stderr=True,
|
result = command.run_pipe([pipe], capture=True, capture_stderr=True,
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
return result.return_code == 0
|
return result.return_code == 0
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ def AddWorktree(git_dir, output_dir, commit_hash=None):
|
|||||||
pipe = ['git', '--git-dir', git_dir, 'worktree', 'add', '.', '--detach']
|
pipe = ['git', '--git-dir', git_dir, 'worktree', 'add', '.', '--detach']
|
||||||
if commit_hash:
|
if commit_hash:
|
||||||
pipe.append(commit_hash)
|
pipe.append(commit_hash)
|
||||||
result = command.RunPipe([pipe], capture=True, cwd=output_dir,
|
result = command.run_pipe([pipe], capture=True, cwd=output_dir,
|
||||||
capture_stderr=True)
|
capture_stderr=True)
|
||||||
if result.return_code != 0:
|
if result.return_code != 0:
|
||||||
raise OSError('git worktree add: %s' % result.stderr)
|
raise OSError('git worktree add: %s' % result.stderr)
|
||||||
@ -301,7 +301,7 @@ def PruneWorktrees(git_dir):
|
|||||||
git_dir: The repository whose deleted worktrees should be pruned
|
git_dir: The repository whose deleted worktrees should be pruned
|
||||||
"""
|
"""
|
||||||
pipe = ['git', '--git-dir', git_dir, 'worktree', 'prune']
|
pipe = ['git', '--git-dir', git_dir, 'worktree', 'prune']
|
||||||
result = command.RunPipe([pipe], capture=True, capture_stderr=True)
|
result = command.run_pipe([pipe], capture=True, capture_stderr=True)
|
||||||
if result.return_code != 0:
|
if result.return_code != 0:
|
||||||
raise OSError('git worktree prune: %s' % result.stderr)
|
raise OSError('git worktree prune: %s' % result.stderr)
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ def CreatePatches(branch, start, count, ignore_binary, series, signoff = True):
|
|||||||
brname = branch or 'HEAD'
|
brname = branch or 'HEAD'
|
||||||
cmd += ['%s~%d..%s~%d' % (brname, start + count, brname, start)]
|
cmd += ['%s~%d..%s~%d' % (brname, start + count, brname, start)]
|
||||||
|
|
||||||
stdout = command.RunList(cmd)
|
stdout = command.run_list(cmd)
|
||||||
files = stdout.splitlines()
|
files = stdout.splitlines()
|
||||||
|
|
||||||
# We have an extra file if there is a cover letter
|
# We have an extra file if there is a cover letter
|
||||||
@ -397,7 +397,7 @@ def CheckSuppressCCConfig():
|
|||||||
Returns:
|
Returns:
|
||||||
True if the option is configured correctly, False otherwise.
|
True if the option is configured correctly, False otherwise.
|
||||||
"""
|
"""
|
||||||
suppresscc = command.OutputOneLine('git', 'config', 'sendemail.suppresscc',
|
suppresscc = command.output_one_line('git', 'config', 'sendemail.suppresscc',
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
|
|
||||||
# Other settings should be fine.
|
# Other settings should be fine.
|
||||||
@ -477,7 +477,7 @@ send --cc-cmd cc-fname" cover p1 p2'
|
|||||||
"""
|
"""
|
||||||
to = BuildEmailList(series.get('to'), '--to', alias, warn_on_error)
|
to = BuildEmailList(series.get('to'), '--to', alias, warn_on_error)
|
||||||
if not to:
|
if not to:
|
||||||
git_config_to = command.Output('git', 'config', 'sendemail.to',
|
git_config_to = command.output('git', 'config', 'sendemail.to',
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
if not git_config_to:
|
if not git_config_to:
|
||||||
print("No recipient.\n"
|
print("No recipient.\n"
|
||||||
@ -606,7 +606,7 @@ def GetTopLevel():
|
|||||||
os.path.join(GetTopLevel(), 'tools', 'patman')
|
os.path.join(GetTopLevel(), 'tools', 'patman')
|
||||||
True
|
True
|
||||||
"""
|
"""
|
||||||
return command.OutputOneLine('git', 'rev-parse', '--show-toplevel')
|
return command.output_one_line('git', 'rev-parse', '--show-toplevel')
|
||||||
|
|
||||||
def GetAliasFile():
|
def GetAliasFile():
|
||||||
"""Gets the name of the git alias file.
|
"""Gets the name of the git alias file.
|
||||||
@ -614,7 +614,7 @@ def GetAliasFile():
|
|||||||
Returns:
|
Returns:
|
||||||
Filename of git alias file, or None if none
|
Filename of git alias file, or None if none
|
||||||
"""
|
"""
|
||||||
fname = command.OutputOneLine('git', 'config', 'sendemail.aliasesfile',
|
fname = command.output_one_line('git', 'config', 'sendemail.aliasesfile',
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
if not fname:
|
if not fname:
|
||||||
return None
|
return None
|
||||||
@ -631,7 +631,7 @@ def GetDefaultUserName():
|
|||||||
Returns:
|
Returns:
|
||||||
User name found in .gitconfig file, or None if none
|
User name found in .gitconfig file, or None if none
|
||||||
"""
|
"""
|
||||||
uname = command.OutputOneLine('git', 'config', '--global', 'user.name')
|
uname = command.output_one_line('git', 'config', '--global', 'user.name')
|
||||||
return uname
|
return uname
|
||||||
|
|
||||||
def GetDefaultUserEmail():
|
def GetDefaultUserEmail():
|
||||||
@ -640,7 +640,7 @@ def GetDefaultUserEmail():
|
|||||||
Returns:
|
Returns:
|
||||||
User's email found in .gitconfig file, or None if none
|
User's email found in .gitconfig file, or None if none
|
||||||
"""
|
"""
|
||||||
uemail = command.OutputOneLine('git', 'config', '--global', 'user.email')
|
uemail = command.output_one_line('git', 'config', '--global', 'user.email')
|
||||||
return uemail
|
return uemail
|
||||||
|
|
||||||
def GetDefaultSubjectPrefix():
|
def GetDefaultSubjectPrefix():
|
||||||
@ -649,7 +649,7 @@ def GetDefaultSubjectPrefix():
|
|||||||
Returns:
|
Returns:
|
||||||
Subject prefix found in local .git/config file, or None if none
|
Subject prefix found in local .git/config file, or None if none
|
||||||
"""
|
"""
|
||||||
sub_prefix = command.OutputOneLine('git', 'config', 'format.subjectprefix',
|
sub_prefix = command.output_one_line('git', 'config', 'format.subjectprefix',
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
|
|
||||||
return sub_prefix
|
return sub_prefix
|
||||||
@ -663,7 +663,7 @@ def Setup():
|
|||||||
if alias_fname:
|
if alias_fname:
|
||||||
settings.ReadGitAliases(alias_fname)
|
settings.ReadGitAliases(alias_fname)
|
||||||
cmd = LogCmd(None, count=0)
|
cmd = LogCmd(None, count=0)
|
||||||
use_no_decorate = (command.RunPipe([cmd], raise_on_error=False)
|
use_no_decorate = (command.run_pipe([cmd], raise_on_error=False)
|
||||||
.return_code == 0)
|
.return_code == 0)
|
||||||
|
|
||||||
def GetHead():
|
def GetHead():
|
||||||
@ -672,7 +672,7 @@ def GetHead():
|
|||||||
Returns:
|
Returns:
|
||||||
Hash of HEAD
|
Hash of HEAD
|
||||||
"""
|
"""
|
||||||
return command.OutputOneLine('git', 'show', '-s', '--pretty=format:%H')
|
return command.output_one_line('git', 'show', '-s', '--pretty=format:%H')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
|
@ -700,7 +700,7 @@ def get_list(commit_range, git_dir=None, count=None):
|
|||||||
"""
|
"""
|
||||||
params = gitutil.LogCmd(commit_range, reverse=True, count=count,
|
params = gitutil.LogCmd(commit_range, reverse=True, count=count,
|
||||||
git_dir=git_dir)
|
git_dir=git_dir)
|
||||||
return command.RunPipe([params], capture=True).stdout
|
return command.run_pipe([params], capture=True).stdout
|
||||||
|
|
||||||
def get_metadata_for_list(commit_range, git_dir=None, count=None,
|
def get_metadata_for_list(commit_range, git_dir=None, count=None,
|
||||||
series=None, allow_overwrite=False):
|
series=None, allow_overwrite=False):
|
||||||
|
@ -61,7 +61,7 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None,
|
|||||||
'--omit "%s" %s %s %s -P1' % (prefix, ','.join(glob_list),
|
'--omit "%s" %s %s %s -P1' % (prefix, ','.join(glob_list),
|
||||||
prog, extra_args or '', test_cmd))
|
prog, extra_args or '', test_cmd))
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
stdout = command.Output('python3-coverage', 'report')
|
stdout = command.output('python3-coverage', 'report')
|
||||||
lines = stdout.splitlines()
|
lines = stdout.splitlines()
|
||||||
if required:
|
if required:
|
||||||
# Convert '/path/to/name.py' just the module name 'name'
|
# Convert '/path/to/name.py' just the module name 'name'
|
||||||
|
@ -360,7 +360,7 @@ def run_result(name, *args, **kwargs):
|
|||||||
args = tuple(extra_args) + args
|
args = tuple(extra_args) + args
|
||||||
name = os.path.expanduser(name) # Expand paths containing ~
|
name = os.path.expanduser(name) # Expand paths containing ~
|
||||||
all_args = (name,) + args
|
all_args = (name,) + args
|
||||||
result = command.RunPipe([all_args], capture=True, capture_stderr=True,
|
result = command.run_pipe([all_args], capture=True, capture_stderr=True,
|
||||||
env=env, raise_on_error=False, binary=binary)
|
env=env, raise_on_error=False, binary=binary)
|
||||||
if result.return_code:
|
if result.return_code:
|
||||||
if raise_on_error:
|
if raise_on_error:
|
||||||
@ -545,7 +545,7 @@ def print_full_help(fname):
|
|||||||
pager = [lesspath] if lesspath else None
|
pager = [lesspath] if lesspath else None
|
||||||
if not pager:
|
if not pager:
|
||||||
pager = ['more']
|
pager = ['more']
|
||||||
command.Run(*pager, fname)
|
command.run(*pager, fname)
|
||||||
|
|
||||||
def download(url, tmpdir_pattern='.patman'):
|
def download(url, tmpdir_pattern='.patman'):
|
||||||
"""Download a file to a temporary directory
|
"""Download a file to a temporary directory
|
||||||
|
@ -44,17 +44,17 @@ def rm_kconfig_include(path):
|
|||||||
path: Path to search for and remove
|
path: Path to search for and remove
|
||||||
"""
|
"""
|
||||||
cmd = ['git', 'grep', path]
|
cmd = ['git', 'grep', path]
|
||||||
stdout = command.RunPipe([cmd], capture=True, raise_on_error=False).stdout
|
stdout = command.run_pipe([cmd], capture=True, raise_on_error=False).stdout
|
||||||
if not stdout:
|
if not stdout:
|
||||||
return
|
return
|
||||||
fname = stdout.split(':')[0]
|
fname = stdout.split(':')[0]
|
||||||
|
|
||||||
print("Fixing up '%s' to remove reference to '%s'" % (fname, path))
|
print("Fixing up '%s' to remove reference to '%s'" % (fname, path))
|
||||||
cmd = ['sed', '-i', '\|%s|d' % path, fname]
|
cmd = ['sed', '-i', '\|%s|d' % path, fname]
|
||||||
stdout = command.RunPipe([cmd], capture=True).stdout
|
stdout = command.run_pipe([cmd], capture=True).stdout
|
||||||
|
|
||||||
cmd = ['git', 'add', fname]
|
cmd = ['git', 'add', fname]
|
||||||
stdout = command.RunPipe([cmd], capture=True).stdout
|
stdout = command.run_pipe([cmd], capture=True).stdout
|
||||||
|
|
||||||
def rm_board(board):
|
def rm_board(board):
|
||||||
"""Create a commit which removes a single board
|
"""Create a commit which removes a single board
|
||||||
@ -69,7 +69,7 @@ def rm_board(board):
|
|||||||
|
|
||||||
# Find all MAINTAINERS and Kconfig files which mention the board
|
# Find all MAINTAINERS and Kconfig files which mention the board
|
||||||
cmd = ['git', 'grep', '-l', board]
|
cmd = ['git', 'grep', '-l', board]
|
||||||
stdout = command.RunPipe([cmd], capture=True).stdout
|
stdout = command.run_pipe([cmd], capture=True).stdout
|
||||||
maintain = []
|
maintain = []
|
||||||
kconfig = []
|
kconfig = []
|
||||||
for line in stdout.splitlines():
|
for line in stdout.splitlines():
|
||||||
@ -110,7 +110,7 @@ def rm_board(board):
|
|||||||
# which reference Kconfig files we want to remove
|
# which reference Kconfig files we want to remove
|
||||||
for path in real:
|
for path in real:
|
||||||
cmd = ['find', path]
|
cmd = ['find', path]
|
||||||
stdout = (command.RunPipe([cmd], capture=True, raise_on_error=False).
|
stdout = (command.run_pipe([cmd], capture=True, raise_on_error=False).
|
||||||
stdout)
|
stdout)
|
||||||
for fname in stdout.splitlines():
|
for fname in stdout.splitlines():
|
||||||
if fname.endswith('Kconfig'):
|
if fname.endswith('Kconfig'):
|
||||||
@ -118,7 +118,7 @@ def rm_board(board):
|
|||||||
|
|
||||||
# Remove unwanted files
|
# Remove unwanted files
|
||||||
cmd = ['git', 'rm', '-r'] + real
|
cmd = ['git', 'rm', '-r'] + real
|
||||||
stdout = command.RunPipe([cmd], capture=True).stdout
|
stdout = command.run_pipe([cmd], capture=True).stdout
|
||||||
|
|
||||||
## Change the messages as needed
|
## Change the messages as needed
|
||||||
msg = '''arm: Remove %s board
|
msg = '''arm: Remove %s board
|
||||||
@ -132,12 +132,12 @@ Remove it.
|
|||||||
|
|
||||||
# Create the commit
|
# Create the commit
|
||||||
cmd = ['git', 'commit', '-s', '-m', msg]
|
cmd = ['git', 'commit', '-s', '-m', msg]
|
||||||
stdout = command.RunPipe([cmd], capture=True).stdout
|
stdout = command.run_pipe([cmd], capture=True).stdout
|
||||||
|
|
||||||
# Check if the board is mentioned anywhere else. The user will need to deal
|
# Check if the board is mentioned anywhere else. The user will need to deal
|
||||||
# with this
|
# with this
|
||||||
cmd = ['git', 'grep', '-il', board]
|
cmd = ['git', 'grep', '-il', board]
|
||||||
print(command.RunPipe([cmd], capture=True, raise_on_error=False).stdout)
|
print(command.run_pipe([cmd], capture=True, raise_on_error=False).stdout)
|
||||||
print(' '.join(cmd))
|
print(' '.join(cmd))
|
||||||
|
|
||||||
for board in sys.argv[1:]:
|
for board in sys.argv[1:]:
|
||||||
|
Loading…
Reference in New Issue
Block a user