diff options
Diffstat (limited to 'scripts/getstats.py')
-rwxr-xr-x | scripts/getstats.py | 80 |
1 files changed, 46 insertions, 34 deletions
diff --git a/scripts/getstats.py b/scripts/getstats.py index d0b7d59..735b28a 100755 --- a/scripts/getstats.py +++ b/scripts/getstats.py @@ -9,8 +9,10 @@ from getresultdetails2 import GetResultDetails2AsJSON from gettimeseriesstats import GetTimeSeriesStatsAsJSON from gettimeseriesdetails import GetTimeSeriesDetailsAsJSON from getsnapshots import GetSnapshotsAsJSON -from getrankings import GetRankingsAsJSON from settimeseriesnote import SetTimeSeriesNote +from gettopchanges import GetTopChangesAsJSON +from getnamemappings import GetNameMappingsAsJSON +from gettestcaseswithchanges import GetTestCasesWithChangesAsJSON from dbaccess import setDatabase from misc import getOptions, printErrorAsJSON @@ -18,13 +20,25 @@ import sys # --- BEGIN Global functions ---------------------------------------------- +# Returns true iff name exists in options and is true. +def boolOption(options, name): + if name in options: + try: + res = (int(options[name]) != 0) + except: + res = (options[name].lower() == "true") + else: + res = False + return res + + # Returns a command instance. def createCommand(options, http_get): def printUsageError(): error = ( "usage: " + sys.argv[0] + " [--dbhost H --dbport P] --db D + \\\n" - " --cmd contexts [--rankedonly R] | \\\n" + " --cmd contexts | \\\n" " --cmd testcases1 --host H --platform P --branch B " "--sha1 S | \\\n" " --cmd testcases2 --host1 H --platform1 P --branch1 B " @@ -45,11 +59,13 @@ def createCommand(options, http_get): "--durtolmax T --benchmark BM --metric M | \\\n" " --cmd snapshots --host H --platform P " "--branch B --sha11 S --sha12 S | \\\n" - " --cmd rankings --host H --platform P " - "--branch B --sha1 S [--testcasefilter 'TC1 TC2 ...'] " "[--maxsize M] | \\\n" " --cmd settimeseriesnote --host H --platform P " - "--branch B --benchmark B --metric M --note N") + "--branch B --benchmark B --metric M --note N | \\\n" + " --cmd topchanges --regressions R --last L --timescope T " + "--premature P --limit L [--testcasefilter 'TC1 TC2 ...'] | \\\n" + " --cmd namemappings | \\\n" + " --cmd testcaseswithchanges") if http_get: printErrorAsJSON("usage error") @@ -82,15 +98,7 @@ def createCommand(options, http_get): # --- 'contexts' --------------------------------- if cmd == "contexts": - if "rankedonly" in options: - try: - ranked_only = (int(options["rankedonly"]) != 0) - except: - ranked_only = (options["rankedonly"].lower() == "true") - else: - ranked_only = False - - return ListContextsAsJSON(ranked_only) + return ListContextsAsJSON() # --- 'testcases1' --------------------------------- elif cmd == "testcases1": @@ -252,26 +260,6 @@ def createCommand(options, http_get): return GetSnapshotsAsJSON(host, platform, branch, sha11, sha12) - # --- 'rankings' --------------------------------- - elif cmd == "rankings": - if ("host" in options and "platform" in options and - "branch" in options and "sha1" in options): - host = options["host"] - platform = options["platform"] - branch = options["branch"] - sha1 = options["sha1"] - - if "maxsize" in options: - try: - maxsize = int(options["maxsize"]) - except: - raise BaseException("'maxsize' not an integer") - else: - maxsize = 10 - - return GetRankingsAsJSON( - host, platform, branch, sha1, test_case_filter, maxsize) - # --- 'settimeseriesnote' --------------------------------- # ### Hm ... this command doesn't really get statistics, so maybe # rename getstats.py to something more generic @@ -290,6 +278,30 @@ def createCommand(options, http_get): return SetTimeSeriesNote( host, platform, branch, benchmark, metric, note) + # --- 'topchanges' --------------------------------- + elif cmd == "topchanges": + if ("regressions" in options and "last" in options and + "timescope" in options and "premature" in options and + "limit" in options): + regressions = boolOption(options, "regressions") + last = boolOption(options, "last") + timescope = int(options["timescope"]) + premature = boolOption(options, "premature") + limit = int(options["limit"]) + + return GetTopChangesAsJSON( + test_case_filter, regressions, last, timescope, premature, + limit) + + # --- 'namemappings' --------------------------------- + elif cmd == "namemappings": + return GetNameMappingsAsJSON() + + # --- 'testcaseswithchanges' --------------------------------- + elif cmd == "testcaseswithchanges": + return GetTestCasesWithChangesAsJSON() + + # No match: printUsageError() sys.exit(1) |