diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2019-04-12 07:38:24 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-05-28 17:37:45 -0400 |
commit | 1ed7f47fd3af3c09d2cd64d1aff1c5b96d238111 (patch) | |
tree | 8c99c153c9e128d9ffeb3226ae7abc7a65c6c928 /tools/perf/scripts/python/exported-sql-viewer.py | |
parent | c6aba1bf258ff1ce201f112dafe1bdde601573dd (diff) |
perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
The argparse module makes it easier to add new arguments.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-3-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
-rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index 9ff92a130655..498b79454012 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
@@ -91,6 +91,7 @@ | |||
91 | from __future__ import print_function | 91 | from __future__ import print_function |
92 | 92 | ||
93 | import sys | 93 | import sys |
94 | import argparse | ||
94 | import weakref | 95 | import weakref |
95 | import threading | 96 | import threading |
96 | import string | 97 | import string |
@@ -3361,18 +3362,26 @@ class DBRef(): | |||
3361 | # Main | 3362 | # Main |
3362 | 3363 | ||
3363 | def Main(): | 3364 | def Main(): |
3364 | if (len(sys.argv) < 2): | 3365 | usage_str = "exported-sql-viewer.py [--pyside-version-1] <database name>\n" \ |
3365 | printerr("Usage is: exported-sql-viewer.py {<database name> | --help-only}"); | 3366 | " or: exported-sql-viewer.py --help-only" |
3366 | raise Exception("Too few arguments") | 3367 | ap = argparse.ArgumentParser(usage = usage_str, add_help = False) |
3367 | 3368 | ap.add_argument("dbname", nargs="?") | |
3368 | dbname = sys.argv[1] | 3369 | ap.add_argument("--help-only", action='store_true') |
3369 | if dbname == "--help-only": | 3370 | args = ap.parse_args() |
3371 | |||
3372 | if args.help_only: | ||
3370 | app = QApplication(sys.argv) | 3373 | app = QApplication(sys.argv) |
3371 | mainwindow = HelpOnlyWindow() | 3374 | mainwindow = HelpOnlyWindow() |
3372 | mainwindow.show() | 3375 | mainwindow.show() |
3373 | err = app.exec_() | 3376 | err = app.exec_() |
3374 | sys.exit(err) | 3377 | sys.exit(err) |
3375 | 3378 | ||
3379 | dbname = args.dbname | ||
3380 | if dbname is None: | ||
3381 | ap.print_usage() | ||
3382 | print("Too few arguments") | ||
3383 | sys.exit(1) | ||
3384 | |||
3376 | is_sqlite3 = False | 3385 | is_sqlite3 = False |
3377 | try: | 3386 | try: |
3378 | f = open(dbname, "rb") | 3387 | f = open(dbname, "rb") |