summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2011-03-30 12:06:37 +0200
committerjasplin <qt-info@nokia.com>2011-03-30 12:06:37 +0200
commite56e8acba449d5176d741c2d209a7c2c58c2b3bc (patch)
tree47c3255958a09dd5a918f365045c79f70a5253e8
parent660b96ea46529dbe2780460e09281853d77a4c98 (diff)
Added --remote option.
The --remote option allows the upload script to be run either on gitestr (remote = 0) or on another host (remote = 1). When running on gitestr, 'cp' will be used instead of 'scp' etc. The reason we need this is that scp to gitestr currently doesn't work when the script is run in gitestr itself (the command is trying to access another (apparently unrelated) host for some reason).
-rwxr-xr-xscripts/uploadresults.py99
1 files changed, 62 insertions, 37 deletions
diff --git a/scripts/uploadresults.py b/scripts/uploadresults.py
index f373c85..60c16a6 100755
--- a/scripts/uploadresults.py
+++ b/scripts/uploadresults.py
@@ -13,8 +13,8 @@ from misc import (
def printUsage():
sys.stderr.write(
"usage: " + sys.argv[0] +
- " --help | [--dbhost H --dbport P] --db D --host H --platform P "
- "--branch B --sha1 S --file F\n")
+ " --help | [--remote R] [--dbhost H --dbport P] --db D --host H "
+ "--platform P --branch B --sha1 S --file F\n")
def printVerboseUsage():
@@ -23,6 +23,9 @@ def printVerboseUsage():
sys.stderr.write(
" --help: This help.\n")
sys.stderr.write(
+ " --remote: A flag (0 or 1; default = 0) indicating whether this "
+ "script runs on a different server than gitestr.nokia.troll.no.\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")
@@ -336,8 +339,8 @@ def execComputeRankings(options, new_context):
# Executes an external command. Returns True iff the return code of the
# command is zero.
-def runCommand(cmd):
- p = Popen(cmd, stdout = PIPE, stderr = PIPE)
+def runCommand(cmd, cwd_ = None):
+ p = Popen(cmd, cwd = cwd_, stdout = PIPE, stderr = PIPE)
stdout, stderr = p.communicate()
if p.returncode != 0:
print "\nfailed to run command", cmd
@@ -348,7 +351,15 @@ def runCommand(cmd):
return True
-def updateTestableSnapshotsFile():
+# Updates a 'testable snapshots' file on gitestr.nokia.troll.no that can be
+# used by external test clients to determine the most recent snapshot (SHA-1)
+# of each branch and also how many uploads have been completed by each
+# host/platform combination for these branch/snapshot combinations.
+#
+# This script is assumed to run on a different host than
+# gitestr.nokia.troll.no iff the 'remote' argument is True.
+#
+def updateTestableSnapshotsFile(remote):
# --- BEGIN create XML structure ---
impl = getDOMImplementation()
@@ -398,37 +409,50 @@ def updateTestableSnapshotsFile():
f.write(doc.toprettyxml(indent=' '))
f.close()
- # Add new revision (for source control):
- repo_user_at_host = "qt@bmc.test.qt.nokia.com"
- repo_dir = "bmtestable"
- if not runCommand(
- ["scp", tmp_abs_fpath,
- repo_user_at_host + ":" + repo_dir + "/" + file_name]):
- sys.stderr.write("exiting ...\n")
- sys.exit(1)
- if not runCommand(
- ["ssh", repo_user_at_host, "cd " + repo_dir,
- "; git commit -a -m update"]): # Note semicolon!
- sys.stderr.write(
- file_name + " was expected to change, but apparently did not\n")
- sys.stderr.write("exiting ...\n")
- sys.exit(1)
-
- # Install at destination (accessible to external clients):
- # (note: the installation is done in two steps in order to minimize the
- # likelihood of a client reading an incomplete file)
- dest_user_at_host = "qt@gitestr.nokia.troll.no"
- if not runCommand(
- ["scp", tmp_abs_fpath, dest_user_at_host + ":" + tmp_abs_fpath]):
- sys.stderr.write("exiting ...\n")
- sys.exit(1)
- if not runCommand(
- ["ssh", dest_user_at_host, "mv " + tmp_abs_fpath + " " + file_name]):
- sys.stderr.write("exiting ...\n")
- sys.exit(1)
-
- # Clean up local file:
- runCommand(["rm", "-f", tmp_abs_fpath])
+ repo_dir = "/home/qt/bmtestable"
+
+ if remote: # script runs on a different host than gitestr.nokia.troll.no
+
+ gitestr_user_at_host = "qt@gitestr.nokia.troll.no"
+
+ # Install file:
+ # (note: copying the file to the repository is done in two steps
+ # in order to minimize the likelihood of a client reading an
+ # incomplete file)
+ repo_dir = "/home/qt/bmtestable"
+ if not runCommand(
+ ["scp", tmp_abs_fpath, gitestr_user_at_host + ":" + tmp_abs_fpath]):
+ sys.stderr.write("exiting ...\n")
+ sys.exit(1)
+ runCommand(["rm", "-f", tmp_abs_fpath]) # don't need this anymore
+ if not runCommand(
+ ["ssh", gitestr_user_at_host,
+ "mv " + tmp_abs_fpath + " " + repo_dir]):
+ sys.stderr.write("exiting ...\n")
+ sys.exit(1)
+
+ # Commit (for source control):
+ if not runCommand(
+ ["ssh", gitestr_user_at_host, "cd " + repo_dir,
+ "; git commit -a -m update"]): # Note semicolon!
+ sys.stderr.write(
+ file_name + " was expected to change, but apparently did not\n")
+ sys.stderr.write("exiting ...\n")
+ sys.exit(1)
+
+ else: # script runs locally on gitestr.nokia.troll.no
+
+ # Install file:
+ if not runCommand(["mv", tmp_abs_fpath, "."], repo_dir):
+ sys.stderr.write("exiting ...\n")
+ sys.exit(1)
+
+ # Commit (for source control):
+ if not runCommand(["git", "commit", "-a", "-m", "update"], repo_dir):
+ sys.stderr.write(
+ file_name + " was expected to change, but apparently did not\n")
+ sys.stderr.write("exiting ...\n")
+ sys.exit(1)
@@ -544,7 +568,8 @@ if options["db"] == "bm": # this is only supported for the 'bm' database
sys.stdout.write(
"updating 'testable snapshots' file for external testers ...")
sys.stdout.flush()
- updateTestableSnapshotsFile()
+ updateTestableSnapshotsFile(
+ ("remote" in options) and (options["remote"] == "1"))
sys.stdout.write("done\n")