mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
perf test: Update attr.py to use argparse
optparse is deprecated since Python 3.2 and triggers a pylint deprecated-module warning on newer versions of pylint. Replace optparse.OptionParser in tools/perf/tests/shell/lib/attr.py with argparse.ArgumentParser. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
4aa0d84669
commit
cd116fcbc0
|
|
@ -4,7 +4,7 @@ import configparser
|
|||
import os
|
||||
import sys
|
||||
import glob
|
||||
import optparse
|
||||
import argparse
|
||||
import platform
|
||||
import tempfile
|
||||
import logging
|
||||
|
|
@ -426,29 +426,20 @@ def setup_log(verbose):
|
|||
ch.setFormatter(formatter)
|
||||
log.addHandler(ch)
|
||||
|
||||
USAGE = '''%s [OPTIONS]
|
||||
-d dir # tests dir
|
||||
-p path # perf binary
|
||||
-t test # single test
|
||||
-v # verbose level
|
||||
''' % sys.argv[0]
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser(usage=USAGE)
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_option("-t", "--test",
|
||||
action="store", type="string", dest="test")
|
||||
parser.add_option("-d", "--test-dir",
|
||||
action="store", type="string", dest="test_dir")
|
||||
parser.add_option("-p", "--perf",
|
||||
action="store", type="string", dest="perf")
|
||||
parser.add_option("-v", "--verbose",
|
||||
default=0, action="count", dest="verbose")
|
||||
parser.add_argument("-t", "--test",
|
||||
action="store", dest="test", help="single test")
|
||||
parser.add_argument("-d", "--test-dir",
|
||||
action="store", dest="test_dir", help="tests dir")
|
||||
parser.add_argument("-p", "--perf",
|
||||
action="store", dest="perf", help="perf binary")
|
||||
parser.add_argument("-v", "--verbose",
|
||||
default=0, action="count", dest="verbose",
|
||||
help="verbose level")
|
||||
|
||||
options, args = parser.parse_args()
|
||||
if args:
|
||||
parser.error('FAILED wrong arguments %s' % ' '.join(args))
|
||||
return -1
|
||||
options = parser.parse_args()
|
||||
|
||||
setup_log(options.verbose)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user