summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-07-24 10:35:23 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-07-24 10:35:23 +0200
commitff7ae7d90b468b3be5e2a5e1869b1705e6782804 (patch)
treef5a9d56d1aab4bb9e1ee02ba753fc5128dc0f789
parent19110e6724f2ad0359e0d57733854f9101231631 (diff)
bin: Port everything else from deprecated OptionParser to ArgumentParser
-rwxr-xr-xbin/insanity-compare1
-rwxr-xr-xbin/insanity-dbmerge16
-rwxr-xr-xbin/insanity-dumpresults28
-rwxr-xr-xbin/insanity-dumpresults-json32
-rwxr-xr-xbin/insanity-grouper1
5 files changed, 40 insertions, 38 deletions
diff --git a/bin/insanity-compare b/bin/insanity-compare
index 7bf41db..8e89a06 100755
--- a/bin/insanity-compare
+++ b/bin/insanity-compare
@@ -27,7 +27,6 @@ Compare two testruns
import sys
import time
-from optparse import OptionParser
from insanity.storage.sqlite import SQLiteStorage
from insanity.log import initLogging
diff --git a/bin/insanity-dbmerge b/bin/insanity-dbmerge
index 40d8255..23ec992 100755
--- a/bin/insanity-dbmerge
+++ b/bin/insanity-dbmerge
@@ -25,7 +25,7 @@ Tool to merge testruns from one DBStorage to another
"""
import sys
-from optparse import OptionParser
+from argparse import ArgumentParser
from insanity.log import initLogging
from insanity.storage.sqlite import SQLiteStorage
try:
@@ -49,24 +49,24 @@ def make_mysql_storage(uri):
if __name__ == "__main__":
usage = "usage: %prog"
- parser = OptionParser(usage=usage)
- parser.add_option("-t", "--testrun", dest="testrun",
+ parser = ArgumentParser(usage=usage)
+ parser.add_argument("-t", "--testrun", dest="testrun",
help="Specify a testrun id to merge from",
type=int,
default=-1)
- parser.add_option("-o", "--origin", dest="origin",
+ parser.add_argument("-o", "--origin", dest="origin",
help="SQLite DB from which to merge from",
type=str, default=None)
- parser.add_option("-s", "--origin-mysql", dest="origin_mysql",
+ parser.add_argument("-s", "--origin-mysql", dest="origin_mysql",
help="Mysql DB from which to merge from ([user[:password]@]host[:port][/dbname])",
type=str, default=None)
- parser.add_option("-d", "--destination", dest="destination",
+ parser.add_argument("-d", "--destination", dest="destination",
help="SQLite DB to merge into",
type=str, default=None)
- parser.add_option("-y", "--destination-mysql", dest="destination_mysql",
+ parser.add_argument("-y", "--destination-mysql", dest="destination_mysql",
help="Mysql DB to merge into ([user[:password]@]host[:port][/dbname])",
type=str, default=None)
- (options, args) = parser.parse_args(sys.argv[1:])
+ options = parser.parse_args(sys.argv[1:])
if (not (options.origin or options.origin_mysql)) \
and (not (options.destination or options.destination_mysql)):
parser.print_help()
diff --git a/bin/insanity-dumpresults b/bin/insanity-dumpresults
index a06c9cc..3907c8f 100755
--- a/bin/insanity-dumpresults
+++ b/bin/insanity-dumpresults
@@ -27,7 +27,7 @@ Dumps the results of a test results DB
import sys
import time
-from optparse import OptionParser
+from argparse import ArgumentParser
from insanity.log import initLogging
def printTestRunInfo(db, testrunid, verbose=False):
@@ -128,27 +128,29 @@ def printTestRun(db, testrunid, failedonly=False, hidescenarios=False):
printTestInfo(db, testid)
if __name__ == "__main__":
- usage = "usage: %prog database [options]"
- parser = OptionParser(usage=usage)
- parser.add_option("-l", "--list", dest="list",
+ usage = "usage: %s database [options]" % sys.argv[0]
+ parser = ArgumentParser(usage=usage)
+ parser.add_argument("-l", "--list", dest="list",
help="List the available test runs with summary",
action="store_true",
default=False)
- parser.add_option("-t", "--testrun", dest="testrun",
+ parser.add_argument("-t", "--testrun", dest="testrun",
help="Specify a testrun id",
type=int,
default=-1)
- parser.add_option("-f", "--failed", dest="failed",
+ parser.add_argument("-f", "--failed", dest="failed",
help="Only show failed tests",
action="store_true", default=False)
- parser.add_option("-x", "--hidescenarios", dest="hidescenarios",
+ parser.add_argument("-x", "--hidescenarios", dest="hidescenarios",
help="Do not show scenarios",
action="store_true", default=False)
- parser.add_option("-m", "--mysql", dest="usemysql",
+ parser.add_argument("-m", "--mysql", dest="usemysql",
default=False, action="store_true",
help="Connect to a MySQL database for storage")
- (options, args) = parser.parse_args(sys.argv[1:])
- if not options.usemysql and len(args) != 1:
+ parser.add_argument("db", default=None, help="Database")
+
+ options = parser.parse_args(sys.argv[1:])
+ if not options.usemysql and not options.db:
print "You need to specify a database file !"
parser.print_help()
sys.exit()
@@ -159,15 +161,15 @@ if __name__ == "__main__":
except ImportError:
exit(1)
- if len(args):
- kw = MySQLStorage.parse_uri(args[0])
+ if len(options.db) > 0:
+ kw = MySQLStorage.parse_uri(options.db)
db = MySQLStorage(async=False, **kw)
else:
# use default values
db = MySQLStorage(async=False)
else:
from insanity.storage.sqlite import SQLiteStorage
- db = SQLiteStorage(path=args[0], async=False)
+ db = SQLiteStorage(path=options.db, async=False)
if options.list:
# list all available test runs
testruns = db.listTestRuns()
diff --git a/bin/insanity-dumpresults-json b/bin/insanity-dumpresults-json
index 54cdecd..31d60f4 100755
--- a/bin/insanity-dumpresults-json
+++ b/bin/insanity-dumpresults-json
@@ -29,7 +29,7 @@ Dumps the results of a test results DB
import sys
import time
-from optparse import OptionParser
+from argparse import ArgumentParser
from insanity.log import initLogging, warning
import simplejson
@@ -205,36 +205,38 @@ def printTestRuns(db, testrunids, failedonly=False, hidescenarios=False,
print # Newline at end of file.
if __name__ == "__main__":
- usage = "usage: %prog database [options]"
- parser = OptionParser(usage=usage)
- parser.add_option("-l", "--list", dest="list",
+ usage = "usage: %s database [options]" % sys.argv[0]
+ parser = ArgumentParser(usage=usage)
+ parser.add_argument("-l", "--list", dest="list",
help="List the available test runs with summary",
action="store_true",
default=False)
- parser.add_option("-a", "--all", dest="all",
+ parser.add_argument("-a", "--all", dest="all",
help="Dump all testruns.",
action="store_true",
default=False)
- parser.add_option("-t", "--testrun", dest="testrun",
+ parser.add_argument("-t", "--testrun", dest="testrun",
help="Specify a testrun id",
type=int,
default=-1)
- parser.add_option("-i", "--indent", dest="indent",
+ parser.add_argument("-i", "--indent", dest="indent",
help="Indentation for pretty-printed json. "
"Default is to use a compact representation.",
type=int,
default=None)
- parser.add_option("-f", "--failed", dest="failed",
+ parser.add_argument("-f", "--failed", dest="failed",
help="Only show failed tests",
action="store_true", default=False)
- parser.add_option("-x", "--hidescenarios", dest="hidescenarios",
+ parser.add_argument("-x", "--hidescenarios", dest="hidescenarios",
help="Do not show scenarios",
action="store_true", default=False)
- parser.add_option("-m", "--mysql", dest="usemysql",
+ parser.add_argument("-m", "--mysql", dest="usemysql",
default=False, action="store_true",
help="Connect to a MySQL database for storage")
- (options, args) = parser.parse_args(sys.argv[1:])
- if not options.usemysql and len(args) != 1:
+ parser.add_argument("db", default=None, help="Database")
+
+ options = parser.parse_args(sys.argv[1:])
+ if not options.usemysql and not options.db:
print >> sys.stderr, "You need to specify a database file !"
parser.print_help()
sys.exit(1)
@@ -244,15 +246,15 @@ if __name__ == "__main__":
from insanity.storage.mysql import MySQLStorage
except ImportError:
exit(1)
- if len(args):
- kw = MySQLStorage.parse_uri(args[0])
+ if len(options.db) > 0:
+ kw = MySQLStorage.parse_uri(options.db)
db = MySQLStorage(async=False, **kw)
else:
# use default values
db = MySQLStorage(async=False)
else:
from insanity.storage.sqlite import SQLiteStorage
- db = SQLiteStorage(path=args[0], async=False)
+ db = SQLiteStorage(path=options.db, async=False)
if options.list:
# list all available test runs
testruns = db.listTestRuns()
diff --git a/bin/insanity-grouper b/bin/insanity-grouper
index 07440fa..beedead 100755
--- a/bin/insanity-grouper
+++ b/bin/insanity-grouper
@@ -28,7 +28,6 @@ Finds similarities in a testrun and groups them
import sys
import string
import time
-from optparse import OptionParser
from insanity.storage.sqlite import SQLiteStorage
( TRUE_VALIDATED,