summaryrefslogtreecommitdiffstats
path: root/scripts/updateallchanges.py
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2011-05-26 15:07:14 +0200
committerjasplin <qt-info@nokia.com>2011-05-26 15:07:14 +0200
commitcac600fc0a2069e34036c5112ba4cfb8483bb559 (patch)
tree8fba1a4e47113b902582cc6c5f03af909b6e9e73 /scripts/updateallchanges.py
parenteae8ff839296559a637ff100d7585562d68b5cb1 (diff)
Added Top Changes page to replace ranking feature.
This commit introduces the Top Changes page. This page retrieves 'top 10' changes for all host/platform/branch combinations from a new 'change' database table. The script that updates this table for a given host/platform/branch combination is run automatically after uploading a new set of results (since this is when new changes may potentially arise). This commit also removes the ranking feature as this is obsoleted (more or less) by the new feature.
Diffstat (limited to 'scripts/updateallchanges.py')
-rwxr-xr-xscripts/updateallchanges.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/scripts/updateallchanges.py b/scripts/updateallchanges.py
new file mode 100755
index 0000000..e5d81c8
--- /dev/null
+++ b/scripts/updateallchanges.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+
+"""
+This script invokes updatechanges.py for all host/platform/branch combinations.
+"""
+
+import sys
+from subprocess import Popen, PIPE
+from dbaccess import setDatabase, execQuery, commit
+from misc import getOptions, idToText
+
+
+# --- BEGIN Global functions ----------------------------------------------
+
+def printUsage():
+ sys.stderr.write(
+ "usage: " + sys.argv[0] + " --help | [--dbhost H --dbport P] --db D\n")
+
+
+def printVerboseUsage():
+ printUsage()
+ 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).\n")
+
+
+# Executes the external updatechanges.py script with appropriate arguments.
+def execUpdateChanges(host, platform, branch, options):
+
+ cmd = [
+ "updatechanges.py", "--db", options["db"], "--host", host,
+ "--platform", platform, "--branch", branch, "--noprogress", "true"]
+ if "dbhost" in options:
+ cmd += ["--dbhost", options["dbhost"]]
+ if "dbport" in options:
+ cmd += ["--dbport", options["dbport"]]
+
+ sys.stdout.write(
+ "\nupdating changes for " + host + " / " + platform + " / " + branch +
+ " ...\n")
+ sys.stdout.flush()
+
+ p = Popen(cmd, stdout = PIPE, stderr = PIPE)
+ stdout, stderr = p.communicate()
+ if (p.returncode != 0):
+ 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:
+ sys.stdout.write("updatechanges.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 ----------------------------------------------
+
+
+# --- BEGIN Main program ----------------------------------------------
+
+options, http_get = getOptions()
+
+if "help" in options:
+ printVerboseUsage()
+ sys.exit(1)
+
+if not ("db" in options):
+ printUsage()
+ sys.exit(1)
+
+setDatabase(
+ options["dbhost"] if "dbhost" in options else None,
+ options["dbport"] if "dbport" in options else None,
+ options["db"])
+
+hpb_ids = execQuery(
+ "SELECT DISTINCT hostId, platformId, branchId FROM context "
+ "ORDER BY hostId, platformId, branchId", ())
+
+for host_id, platform_id, branch_id in hpb_ids:
+ execUpdateChanges(
+ idToText("host", host_id),
+ idToText("platform", platform_id),
+ idToText("branch", branch_id),
+ options)
+
+sys.exit(0)
+
+# --- END Main program ----------------------------------------------