re #1111 (more on automated tests): added delay option in run_continuous.py to prevent more than one scripts from running simultaneously on a single host

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@3289 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/tests/automated/run_continuous.py b/tests/automated/run_continuous.py
index f3bef0a..fa4b3d4 100755
--- a/tests/automated/run_continuous.py
+++ b/tests/automated/run_continuous.py
@@ -6,6 +6,7 @@
 import ccdash
 
 INTERVAL = 300
+DELAY = 0
 
 def run_scenarios(scenarios, group):
 	# Run each scenario
@@ -23,22 +24,52 @@
 	return rc
 
 
+def usage():
+	print """Periodically monitor working directory for Continuous and Nightly builds
+
+Usage:
+  run_continuous.py [options] scenario1.xml [scenario2.xml ...]
+
+options:
+  These are options which will be processed by run_continuous.py:
+
+  --delay MIN   Delay both Continuous and Nightly builds by MIN minutes. 
+  		This is useful to coordinate the build with other build 
+		machines. By default, Continuous build will be done right
+		after changes are detected, and Nightly build will be done
+		at 00:00 GMT. MIN is a float number.
+
+"""
+	sys.exit(1)
+
 if __name__ == "__main__":
-	if len(sys.argv)<=1 or sys.argv[1]=="-h" or sys.argv[1]=="--h" or sys.argv[1]=="/h":
-		print "This will run both Continuous and Nightly tests"
-		print ""
-		print "Usage: run_continuous.py scenario1.xml [scenario2.xml ...]"
-		print ""
-		sys.exit(1)
+	if len(sys.argv)<=1 or sys.argv[1]=="-h" or sys.argv[1]=="--h" or sys.argv[1]=="--help" or sys.argv[1]=="/h":
+		usage()
 
 	# Splice list
-	scenarios = sys.argv[1:]
+	scenarios = []
+	i = 1
+	while i < len(sys.argv):
+		if sys.argv[i]=="--delay":
+			i = i + 1
+			if i >= len(sys.argv):
+				print "Error: missing argument"
+				sys.exit(1)
+			DELAY = float(sys.argv[i]) * 60
+			print "Delay is set to %f minute(s)" % (DELAY / 60)
+		else:
+			# Check if scenario exists
+			scenario = sys.argv[i]
+			if not os.path.exists(scenario):
+				print "Error: file " + scenario + " does not exist"
+				sys.exit(1)
+			scenario.append(scenario)
+			print "Scenario %s added" % (scenario)
+		i = i + 1
 
-	# Check if scenario exists
-	for scenario in scenarios:
-		if not os.path.exists(scenario):
-			print "Error: file " + scenario + " does not exist"
-			sys.exit(1)
+	if len(scenarios) < 1:
+		print "Error: scenario is required"
+		sys.exit(1)
 
 	# Current date
 	utc = time.gmtime(None)