diff options
Diffstat (limited to 'scripts/uploadresults.py')
-rwxr-xr-x | scripts/uploadresults.py | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/scripts/uploadresults.py b/scripts/uploadresults.py index f0d5bb3..3fd38a8 100755 --- a/scripts/uploadresults.py +++ b/scripts/uploadresults.py @@ -11,38 +11,40 @@ from misc import ( # --- BEGIN Global functions ---------------------------------------------- def printUsage(): - print ( - "usage:" + sys.argv[0] + + sys.stderr.write( + "usage: " + sys.argv[0] + " --help | [--dbhost H --dbport P] --db D --host H --platform P " - "--branch B --sha1 S --file F") + "--branch B --sha1 S --file F\n") + def printVerboseUsage(): printUsage() - print "\noptions:" - print( - " --help: This help.") - print( - " --dbhost: The database server host (overriding the default).") - print( - " --dbport: The database server port (overriding the default).") - print( + sys.stderr.write("\noptions:\n") + sys.stderr.write( + " --help: This help.\n") + sys.stderr.write( + " --dbhost: The database server host (overriding the default).\n") + sys.stderr.write( + " --dbport: The database server port (overriding the default).\n") + sys.stderr.write( " --db: The database. One of 'bm' or 'bm-dev' (the latter " - "intended for experimentation).") - print( + "intended for experimentation).\n") + sys.stderr.write( " --host: The physical machine on which the results were " - "produced (e.g. barbarella or 172.24.90.79).") - print( + "produced (e.g. barbarella or 172.24.90.79).\n") + sys.stderr.write( "--platform: The OS/compiler/architecture combination " - "(e.g. linux-g++-32).") - print( + "(e.g. linux-g++-32).\n") + sys.stderr.write( " --branch: The product branch (e.g. 'qt 4.6', 'qt 4.7', or " - "'qt master').") - print( + "'qt master').\n") + sys.stderr.write( " --sha1: The tested revision within the branch. Can be " "extracted using 'git log -1 --pretty=format:%H' (assuming the " - "tested revision is the current head revision).") - print( - " --file: The results file in QTestLib XML output format.") + "tested revision is the current head revision).\n") + sys.stderr.write( + " --file: The results file in QTestLib XML output format.\n") + # Returns True iff a low value indicates better performance than a high # value for the given metric. @@ -68,6 +70,7 @@ def canonicalMetric(metric): return "fps" return metric + # Returns True iff at least one of the given incidents indicates failure for # the given data tag. def matchesFailedIncident(dataTag, incidents): @@ -81,6 +84,7 @@ def matchesFailedIncident(dataTag, incidents): return True return False + # Returns results extracted from a file in QTestLib XML format # (note: multiple top-level TestCase elements are allowed). def extractResults(file): @@ -99,9 +103,9 @@ def extractResults(file): try: lowerIsBetter_ = lowerIsBetter(metric) except: - print( + sys.stdout.write( "WARNING: skipping result for unsupported metric: >" + - metric + "<") + metric + "<\n") continue metric = canonicalMetric(metric) @@ -166,15 +170,14 @@ def extractResults(file): return results + # ### 2 B DOCUMENTED! def findOrInsertId(table, value, *args): - #print "value: >" + value + "<, ", query_result = execQuery( "SELECT id FROM " + table + " WHERE value = %s", (value,)) if len(query_result) == 1: # Found, so return ID: - #print "returning existing ID: >" + str(query_result[0][0]) + "<" return query_result[0][0] # Not found, so insert: @@ -192,7 +195,6 @@ def findOrInsertId(table, value, *args): query_result = execQuery(query, values) assert len(query_result) == 1 - #print "returning new ID: >" + str(query_result[0][0]) + "<" return query_result[0][0] @@ -321,16 +323,15 @@ def execComputeRankings(options, new_context): p = Popen(cmd, stdout = PIPE, stderr = PIPE) stdout, stderr = p.communicate() if (p.returncode != 0): - print "failed to execute command '" + str(cmd) + "':" - print " return code:", p.returncode - print " stdout: >%s<" % stdout.strip() - print " stderr: >%s<" % stderr.strip() + sys.stdout.write("failed to execute command '" + str(cmd) + "':\n") + sys.stdout.write(" return code: " + str(p.returncode) + "\n") + sys.stdout.write(" stdout: >" + stdout.strip() + "<\n") + sys.stdout.write(" stderr: >" + stderr.strip() + "<\n") else: - print "computerankings.py executed successfully:" - print " return code:", p.returncode - print " stdout: >%s<" % stdout.strip() - print " stderr: >%s<" % stderr.strip() - + sys.stdout.write("computerankings.py executed successfully:\n") + sys.stdout.write(" return code: " + str(p.returncode) + "\n") + sys.stdout.write(" stdout: >" + stdout.strip() + "<\n") + sys.stdout.write(" stderr: >" + stderr.strip() + "<\n") # --- END Global functions ---------------------------------------------- @@ -341,12 +342,12 @@ options, http_get = getOptions() if "help" in options: printVerboseUsage() - sys.exit(0) + sys.exit(1) if (not ("db" in options and "host" in options and "platform" in options and "branch" in options and "sha1" in options and "file" in options)): printUsage() - sys.exit(0) + sys.exit(1) if not isValidSHA1(options["sha1"]): sys.stderr.write("error: invalid SHA-1: " + options["sha1"] + "\n") @@ -362,7 +363,9 @@ sys.stdout.write("UPLOADING RESULTS, OPTIONS: " + str(options) + "\n") sys.stdout.flush() -# Reject uploading if this context is already complete: +# Reject uploading if this context is already complete (since it could +# modify the input for (and thus invalidate) any rankings computed for +# this snapshot): if contextComplete(options): sys.stderr.write( "this snapshot is already complete for this time series -> uploading " @@ -434,5 +437,6 @@ else: sys.stdout.write("UPLOADING RESULTS DONE\n") +sys.exit(0) # --- END Main program ---------------------------------------------- |