def validateStep (msg, results, TESTCASE):
	DtilLog = open(glob.DlogName, 'a')
	if (results[0]):
		logMsg(DtilLog, msg)
		logMsg(DtilLog, results[1])
		print ("\nSuccess : %s\n\n" %msg)
	else:
		logMsg (DtilLog, "\nFailed : %s\n\n" %msg)
		logMsg (DtilLog, results[1])
		stop (TESTCASE) 
	DtilLog.close()
def STEP (step):
	print (step)
	DtilLog = open(glob.DlogName, 'a')
	logMsg(DtilLog, "*************************************************************************************\n")
	logMsg(DtilLog, step)
	logMsg(DtilLog, "*************************************************************************************\n")
	DtilLog.close()
def stop(TESTCASE):
	# sl = open(glob.SlogName, 'a')
	# log(sl, "TestCase : Fail\n", ColorCode = 'RED')
	# sl.close()
	print('TESTCASE : %s STOPPED DUE TO ERROR' %TESTCASE)
	DtilLog = open(str(glob.DlogName),'a')
	logMsg(DtilLog,"TESTCASE %s STOPPED DUE TO ERROR"%TESTCASE)
	logMsg(DtilLog,"Test Case %s Failed\n"%TESTCASE)
	logMsg(DtilLog,"===============================================================\n")
	DtilLog.write("\n")
	DtilLog.close()
	raise TestException
def finish(t, TESTCASE, testResult):
	# Test Case Finished !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	print('TESTCASE %s Complete'%TESTCASE)
	
	# Calculate testcase duration
	t2 = time.localtime()
	durationsec = time.mktime(t2) - time.mktime(t)
	hours, remainer = divmod(durationsec, 3600)
	minutes, seconds = divmod(remainer, 60)
	duration = '%s Hours, %s Minutes, %s Seconds'%(hours,minutes,seconds)
		
	print ('FINAL RESULTS: %s' %testResult)
	if(testResult == 'PASS'):
		print('Test Case Result: Pass')
		glob.testCasePassed += 1
		sl = open(glob.SlogName, 'a')
		# log(sl, "TestCase %s: Pass\n" %TESTCASE, ColorCode = 'GREEN')
		log(sl, "TestCase : %s\n" %TESTCASE, ColorCode = 'GREEN')
		log(sl, "Objective : %s\n" %glob.testDesc, ColorCode = 'GREEN')
		log(sl, "Result : Pass\n", ColorCode = 'GREEN')
		sl.close()
		DtilLog = open(str(glob.DlogName),'a')
		logMsg(DtilLog,"Test Case %s Passed\n"%TESTCASE)
		logMsg(DtilLog,"Duration: %s\n"%duration)
		logMsg(DtilLog,"===============================================================\n")
		DtilLog.write("\n")
		DtilLog.close()
	else:
		print('Test Case Result: Fail')
		glob.testCaseFailed += 1
		sl = open(glob.SlogName, 'a')
		# log(sl, "TestCase %s: Fail\n" %TESTCASE, ColorCode = 'RED')
		log(sl, "TestCase : %s\n" %TESTCASE, ColorCode = 'RED')
		log(sl, "Objective : %s\n" %glob.testDesc, ColorCode = 'RED')
		log(sl, "Result : Fail\n", ColorCode = 'RED')
		sl.close()
		DtilLog = open(str(glob.DlogName),'a')
		logMsg(DtilLog,"Test Case %s Failed\n"%TESTCASE)
		logMsg(DtilLog,"Duration: %s\n"%duration)
		logMsg(DtilLog,"===============================================================\n")
		DtilLog.write("\n")
		DtilLog.close()