summaryrefslogtreecommitdiffstats
path: root/Controller/Controller.py
blob: 0f8812f72f1295f900bbe9262eea770279a15a2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import sys
import os
import time
import MySQLdb
import subprocess


import classClient #import class socket
import classDb #import class db
import classPing
import classController
from time import sleep



sipNum		= "4661929"
landlnNum	= "076145875681"
unisipNum	= "076120397897"

# Main software

# Check DB connection
db = classDb.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
db.connectDB()
print ""
dbStatus = db.connectDB()


if dbStatus == 1:
	
	# Check Ping to the Every Handler
	sipServer = classPing.Ping('132.230.4.8')
	sipServerStatus = sipServer.ping(3)

	sipGateServer = classPing.Ping('sipgate.de')
	sipGateServerStatus = sipGateServer.ping(3)

	sipLocalServer = classPing.Ping('132.230.252.228')
	sipLocalServerStatus = sipLocalServer.ping(3)

# Fetch The task information from DB
	db.anyTasksToDo()	
	#x = ()

	for item in db.tasksList:
		
		taskID = item[0]
		taskNo = item[1]
		callFrom = item[2]
		callTo = item[3]

		print "Test ID		: " , taskID 
		print "Caller		: " , callFrom
		print "Receiver	: " , callTo

		if callFrom == "sip":
 			if sipServerStatus == 0:
				print "[failed] 500 Server Internal Error"

			else:
			
				if callTo == "gsmrz1":

					x = classController.test('-S',"gsmBox1","4661455")
					x.FuncTest()
					
					db.addResult(taskID, x.testResult)

					if x.repeatTest == True:
						db.insertTaskIn2(callTo,callFrom,taskNo)
			
				if callTo == "gsmrz2":
	
					if gsmBox1Status == 0:
						print "[failed] 500 Server Internal Error"

					else:
						x = classController.test('-S', "gsmBox2", "4661404")
						x.FuncTest()
						
						db.addResult(taskID, x.testResult)

						if x.repeatTest == True:
							db.insertTaskIn2(callTo,callFrom,taskNo)

				if callTo == "gsmrz3":

					if gsmBox2Status == 0:
						print "[failed] 500 Server Internal Error"

					else:
						x = classController.test('-S', "gsmBox3","4661405")
						x.FuncTest()

						db.addResult(taskID, x.testResult)

						if x.repeatTest == True:
							db.insertTaskIn2(callTo,callFrom,taskNo)

				if callTo == "landline":

					if sipGateServerStatus == 0:
						print "[failed] 500 Server Internal Error"
			
					else:
						x = classController.test('-S', '-L',landlnNum)
						x.FuncTest()

						db.addResult(taskID, x.testResult)
			
						if x.repeatTest == True:
							db.insertTaskIn2(callTo,callFrom,taskNo)
						sleep(5)

				if callTo == "localsip":
					if sipLocalServerStatus == 0:
						print "[failed] 500 Server Internal Error"

					else:
						x = classController.test('-S', '-U',unisipNum)
						x.FuncTest()

						db.addResult(taskID, x.testResult)
						sleep(5)

# will exit if DB connection failed
else:
	sys.exit(5)