tools: Convert more tools to be specified in the yaml file.
This commit is contained in:
parent
4473f15dec
commit
af162fcecf
2 changed files with 83 additions and 58 deletions
|
|
@ -119,8 +119,9 @@ def _do_command(command, timeout=None, **kwargs):
|
|||
return _fix_input(stdout), _fix_input(stderr), process.returncode
|
||||
|
||||
|
||||
def _run_command(command, success_status=Status.ok,
|
||||
error_status=Status.problem):
|
||||
def _run_command(command, success_status=None, error_status=None):
|
||||
success_status = Status.ok if success_status is None else success_status
|
||||
error_status = Status.problem if error_status is None else error_status
|
||||
status, output = success_status, ""
|
||||
try:
|
||||
process = subprocess.run(command, stdout=subprocess.PIPE,
|
||||
|
|
@ -515,55 +516,6 @@ def splint(path):
|
|||
return status, fill3.Text(stdout + stderr)
|
||||
|
||||
|
||||
_OBJDUMP_URL = "https://en.wikipedia.org/wiki/Objdump"
|
||||
|
||||
|
||||
@deps(deps={"binutils"}, url=_OBJDUMP_URL, executables={"objdump"})
|
||||
def objdump_headers(path):
|
||||
return _run_command(["objdump", "--all-headers", path], Status.normal)
|
||||
|
||||
|
||||
@deps(deps={"binutils"}, url=_OBJDUMP_URL, executables={"objdump"})
|
||||
def objdump_disassemble(path):
|
||||
return _run_command(
|
||||
["objdump", "--disassemble", "--reloc", "--dynamic-reloc", path],
|
||||
Status.normal)
|
||||
|
||||
|
||||
@deps(deps={"binutils"}, url=_OBJDUMP_URL, executables={"readelf"})
|
||||
def readelf(path):
|
||||
return _run_command(["readelf", "--all", path], Status.normal)
|
||||
|
||||
|
||||
@deps(deps={"unzip"}, url="unzip", executables={"unzip"})
|
||||
def unzip(path):
|
||||
return _run_command(["unzip", "-l", path], Status.normal)
|
||||
|
||||
|
||||
_TAR_URL = "http://www.gnu.org/software/tar/manual/tar.html"
|
||||
|
||||
|
||||
@deps(deps={"tar"}, url=_TAR_URL, executables={"tar"})
|
||||
def tar_gz(path):
|
||||
return _run_command(["tar", "ztvf", path], Status.normal)
|
||||
|
||||
|
||||
@deps(deps={"tar"}, url=_TAR_URL, executables={"tar"})
|
||||
def tar_bz2(path):
|
||||
return _run_command(["tar", "jtvf", path], Status.normal)
|
||||
|
||||
|
||||
@deps(deps={"binutils"}, url="https://linux.die.net/man/1/nm",
|
||||
executables={"nm"})
|
||||
def nm(path):
|
||||
return _run_command(["nm", "--demangle", path], Status.normal)
|
||||
|
||||
|
||||
@deps(deps={"python-pdfminer"}, url="python-pdfminer", executables={"pdf2txt"})
|
||||
def pdf2txt(path):
|
||||
return _run_command(["pdf2txt", path], Status.normal)
|
||||
|
||||
|
||||
@deps(deps={"tidy"}, url="tidy", executables={"tidy"})
|
||||
def html_syntax(path):
|
||||
# Maybe only show errors
|
||||
|
|
@ -578,11 +530,6 @@ def tidy(path):
|
|||
return Status.normal, fill3.Text(stdout)
|
||||
|
||||
|
||||
@deps(deps={"html2text"}, url="html2text", executables={"html2text"})
|
||||
def html2text(path):
|
||||
return _run_command(["html2text", path], Status.normal)
|
||||
|
||||
|
||||
@deps(deps={"bcpp"}, executables={"bcpp"})
|
||||
def bcpp(path):
|
||||
stdout, stderr, returncode = _do_command(["bcpp", "-fi", path])
|
||||
|
|
@ -676,10 +623,14 @@ def git_log(path):
|
|||
return Status.not_applicable, fill3.Text("")
|
||||
|
||||
|
||||
def make_tool_function(dependencies, url, executables, command):
|
||||
def make_tool_function(dependencies, url, executables, command,
|
||||
success_status=None, error_status=None):
|
||||
command = command.split()
|
||||
success_status = None if success_status is None else Status[success_status]
|
||||
error_status = None if error_status is None else Status[error_status]
|
||||
@deps(deps=set(dependencies), url=url, executables=set(executables))
|
||||
def func(path):
|
||||
return _run_command(command.split() + [path])
|
||||
return _run_command(command + [path], success_status, error_status)
|
||||
return func
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,78 @@
|
|||
|
||||
|
||||
# Template:
|
||||
# :
|
||||
# dependencies: []
|
||||
# url:
|
||||
# executables: []
|
||||
# command:
|
||||
# success_status:
|
||||
# error_status:
|
||||
|
||||
|
||||
objdump_headers:
|
||||
dependencies: [binutils]
|
||||
url: https://en.wikipedia.org/wiki/Objdump
|
||||
executables: [objdump]
|
||||
command: objdump --all-headers
|
||||
success_status: normal
|
||||
|
||||
objdump_disassemble:
|
||||
dependencies: [binutils]
|
||||
url: https://en.wikipedia.org/wiki/Objdump
|
||||
executables: [objdump]
|
||||
command: objdump --disassemble --reloc --dynamic-reloc
|
||||
success_status: normal
|
||||
|
||||
readelf:
|
||||
dependencies: [binutils]
|
||||
url: https://en.wikipedia.org/wiki/Objdump
|
||||
executables: [readelf]
|
||||
command: readelf --all
|
||||
success_status: normal
|
||||
|
||||
unzip:
|
||||
dependencies: [unzip]
|
||||
url: unzip
|
||||
executables: [unzip]
|
||||
command: unzip -l
|
||||
success_status: normal
|
||||
|
||||
tar_gz:
|
||||
dependencies: [tar]
|
||||
url: http://www.gnu.org/software/tar/manual/tar.html
|
||||
executables: [tar]
|
||||
command: tar ztvf
|
||||
success_status: normal
|
||||
|
||||
tar_bz2:
|
||||
dependencies: [tar]
|
||||
url: http://www.gnu.org/software/tar/manual/tar.html
|
||||
executables: [tar]
|
||||
command: tar jtvf
|
||||
success_status: normal
|
||||
|
||||
nm:
|
||||
dependencies: [binutils]
|
||||
url: https://linux.die.net/man/1/nm
|
||||
executables: [nm]
|
||||
command: nm --demangle
|
||||
success_status: normal
|
||||
|
||||
pdf2txt:
|
||||
dependencies: [python-pdfminer]
|
||||
url: python-pdfminer
|
||||
executables: [pdf2txt]
|
||||
command: pdf2txt
|
||||
success_status: normal
|
||||
|
||||
html2text:
|
||||
dependencies: [html2text]
|
||||
url: html2text
|
||||
executables: [html2text]
|
||||
command: html2text
|
||||
success_status: normal
|
||||
|
||||
c_syntax_gcc:
|
||||
dependencies: [gcc, g++-6]
|
||||
url: https://gcc.gnu.org/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue