summaryrefslogtreecommitdiffstats
path: root/For Weekly Test
diff options
context:
space:
mode:
Diffstat (limited to 'For Weekly Test')
-rw-r--r--For Weekly Test/19-08-2011/GSM TMobile handler.log72
-rw-r--r--For Weekly Test/19-08-2011/University SIP handler.log34
-rw-r--r--For Weekly Test/19-08-2011/inserttest.py25
-rw-r--r--For Weekly Test/Old/07-07-2011/Controller-SecondType.py308
-rw-r--r--For Weekly Test/Old/07-07-2011/Controller-SecondType_withDB.py339
-rw-r--r--For Weekly Test/Old/07-07-2011/ca_stMa.py153
-rw-r--r--For Weekly Test/Old/07-07-2011/classClient.py66
-rw-r--r--For Weekly Test/Old/07-07-2011/classClient.pycbin0 -> 2759 bytes
-rw-r--r--For Weekly Test/Old/07-07-2011/classDb.py212
-rw-r--r--For Weekly Test/Old/07-07-2011/classDb.pycbin0 -> 5926 bytes
-rw-r--r--For Weekly Test/Old/07-07-2011/classPing.py28
-rw-r--r--For Weekly Test/Old/07-07-2011/classServer.py94
-rw-r--r--For Weekly Test/Old/07-07-2011/classServer.pycbin0 -> 3365 bytes
-rw-r--r--For Weekly Test/Old/07-07-2011/gsmcall2_.py102
-rw-r--r--For Weekly Test/Old/07-07-2011/gsmcall_.py105
-rw-r--r--For Weekly Test/Old/07-07-2011/gsmincom_.py155
-rw-r--r--For Weekly Test/Old/07-07-2011/sipCall.py176
-rw-r--r--For Weekly Test/Old/07-07-2011/sipReceiver.py177
-rw-r--r--For Weekly Test/Old/15-07-2011/Controller-SecondType.py308
-rw-r--r--For Weekly Test/Old/15-07-2011/Controller-SecondType_withDB.py342
-rw-r--r--For Weekly Test/Old/15-07-2011/LandlineCall.py166
-rw-r--r--For Weekly Test/Old/15-07-2011/LandlineReceiver.py160
-rw-r--r--For Weekly Test/Old/15-07-2011/classClient.py66
-rw-r--r--For Weekly Test/Old/15-07-2011/classClient.pycbin0 -> 2759 bytes
-rw-r--r--For Weekly Test/Old/15-07-2011/classDb.py212
-rw-r--r--For Weekly Test/Old/15-07-2011/classDb.pycbin0 -> 5926 bytes
-rw-r--r--For Weekly Test/Old/15-07-2011/classPing.py28
-rw-r--r--For Weekly Test/Old/15-07-2011/classPing.pycbin0 -> 1283 bytes
-rw-r--r--For Weekly Test/Old/15-07-2011/classServer.py94
-rw-r--r--For Weekly Test/Old/15-07-2011/classServer.pycbin0 -> 3365 bytes
-rw-r--r--For Weekly Test/Old/15-07-2011/gsmcall2_.py102
-rw-r--r--For Weekly Test/Old/15-07-2011/gsmcall_.py105
-rw-r--r--For Weekly Test/Old/15-07-2011/gsmincom_.py134
-rw-r--r--For Weekly Test/Old/15-07-2011/localsipReceiver.py160
-rw-r--r--For Weekly Test/Old/15-07-2011/sipCall.py180
-rw-r--r--For Weekly Test/Old/15-07-2011/sipReceiver.py177
-rw-r--r--For Weekly Test/Old/20-07-2011/Controller.py183
-rw-r--r--For Weekly Test/Old/20-07-2011/LogFileClass.py21
-rw-r--r--For Weekly Test/Old/20-07-2011/LogFileClass.pycbin0 -> 1534 bytes
-rw-r--r--For Weekly Test/Old/20-07-2011/Testing.py44
-rw-r--r--For Weekly Test/Old/20-07-2011/UniSIPRecHandler.log15
-rw-r--r--For Weekly Test/Old/20-07-2011/classClient.py123
-rw-r--r--For Weekly Test/Old/20-07-2011/classClient.pycbin0 -> 3673 bytes
-rw-r--r--For Weekly Test/Old/20-07-2011/classController.py239
-rw-r--r--For Weekly Test/Old/20-07-2011/classController.pycbin0 -> 4893 bytes
-rw-r--r--For Weekly Test/Old/20-07-2011/classDB.py271
-rw-r--r--For Weekly Test/Old/20-07-2011/classDb.pycbin0 -> 5978 bytes
-rw-r--r--For Weekly Test/Old/20-07-2011/classPing.py28
-rw-r--r--For Weekly Test/Old/20-07-2011/classPing.pycbin0 -> 1283 bytes
-rw-r--r--For Weekly Test/Old/20-07-2011/classServer.py152
-rw-r--r--For Weekly Test/Old/20-07-2011/classServer.pycbin0 -> 4651 bytes
-rw-r--r--For Weekly Test/Old/20-07-2011/gsmcall_.py105
-rw-r--r--For Weekly Test/Old/20-07-2011/gsmincom_.py148
-rw-r--r--For Weekly Test/Old/20-07-2011/landlineCall.py135
-rw-r--r--For Weekly Test/Old/20-07-2011/landlineReceiver.py111
-rw-r--r--For Weekly Test/Old/20-07-2011/localsipReceiver.py112
-rw-r--r--For Weekly Test/Old/20-07-2011/sipCall.py135
-rw-r--r--For Weekly Test/Old/20-07-2011/sipCallHandler.log112
-rw-r--r--For Weekly Test/Old/20-07-2011/sipReceiver.py111
-rw-r--r--For Weekly Test/Old/23-07-2011/2classController.py141
-rw-r--r--For Weekly Test/Old/23-07-2011/2sipHandler.py182
-rw-r--r--For Weekly Test/Old/23-07-2011/Controller.py54
-rw-r--r--For Weekly Test/Old/23-07-2011/LogFileClass.py21
-rw-r--r--For Weekly Test/Old/23-07-2011/LogFileClass.pycbin0 -> 1514 bytes
-rw-r--r--For Weekly Test/Old/23-07-2011/Testing.py44
-rw-r--r--For Weekly Test/Old/23-07-2011/classCheck.py28
-rw-r--r--For Weekly Test/Old/23-07-2011/classClient.py122
-rw-r--r--For Weekly Test/Old/23-07-2011/classClient.pycbin0 -> 3637 bytes
-rw-r--r--For Weekly Test/Old/23-07-2011/classController.log91
-rw-r--r--For Weekly Test/Old/23-07-2011/classController.py154
-rw-r--r--For Weekly Test/Old/23-07-2011/classController.pycbin0 -> 3708 bytes
-rw-r--r--For Weekly Test/Old/23-07-2011/classDB.py271
-rw-r--r--For Weekly Test/Old/23-07-2011/classDb.pycbin0 -> 5978 bytes
-rw-r--r--For Weekly Test/Old/23-07-2011/classPing.py28
-rw-r--r--For Weekly Test/Old/23-07-2011/classPing.pycbin0 -> 1267 bytes
-rw-r--r--For Weekly Test/Old/23-07-2011/classServer.py152
-rw-r--r--For Weekly Test/Old/23-07-2011/classServer.pycbin0 -> 4607 bytes
-rw-r--r--For Weekly Test/Old/23-07-2011/sipHandler.log252
-rw-r--r--For Weekly Test/Old/23-07-2011/sipHandler.py189
-rw-r--r--For Weekly Test/Old/23-07-2011/test.py8
-rw-r--r--For Weekly Test/Old/23-07-2011/test1.py7
-rw-r--r--For Weekly Test/Old/23-07-2011/testing.log8
-rw-r--r--For Weekly Test/Old/23-07-2011/testingcc.log4
-rw-r--r--For Weekly Test/Old/30-07-2011/ClientClass.py123
-rw-r--r--For Weekly Test/Old/30-07-2011/ClientClass.pycbin0 -> 3601 bytes
-rw-r--r--For Weekly Test/Old/30-07-2011/Controller.py98
-rw-r--r--For Weekly Test/Old/30-07-2011/ControllerClass.py233
-rw-r--r--For Weekly Test/Old/30-07-2011/ControllerClass.pycbin0 -> 6970 bytes
-rw-r--r--For Weekly Test/Old/30-07-2011/DbClass.py295
-rw-r--r--For Weekly Test/Old/30-07-2011/DbClass.pycbin0 -> 8119 bytes
-rw-r--r--For Weekly Test/Old/30-07-2011/GSMClass.py304
-rw-r--r--For Weekly Test/Old/30-07-2011/GSMClass.pycbin0 -> 7176 bytes
-rw-r--r--For Weekly Test/Old/30-07-2011/GSMHandler.py286
-rw-r--r--For Weekly Test/Old/30-07-2011/Landline handler.log210
-rw-r--r--For Weekly Test/Old/30-07-2011/LogFileClass.py21
-rw-r--r--For Weekly Test/Old/30-07-2011/LogFileClass.pycbin0 -> 1494 bytes
-rw-r--r--For Weekly Test/Old/30-07-2011/PingClass.py28
-rw-r--r--For Weekly Test/Old/30-07-2011/PingClass.pycbin0 -> 1251 bytes
-rw-r--r--For Weekly Test/Old/30-07-2011/SIP handler.log168
-rw-r--r--For Weekly Test/Old/30-07-2011/SIPHandler.py229
-rw-r--r--For Weekly Test/Old/30-07-2011/ServerClass.py152
-rw-r--r--For Weekly Test/Old/30-07-2011/ServerClass.pycbin0 -> 4563 bytes
-rw-r--r--For Weekly Test/Old/30-07-2011/TestProcessLog.log200
-rw-r--r--For Weekly Test/Old/30-07-2011/gsmselftest.py293
-rw-r--r--For Weekly Test/Old/30-07-2011/help.txt11
-rw-r--r--For Weekly Test/Old/30-07-2011/true table.txt43
106 files changed, 10775 insertions, 0 deletions
diff --git a/For Weekly Test/19-08-2011/GSM TMobile handler.log b/For Weekly Test/19-08-2011/GSM TMobile handler.log
new file mode 100644
index 0000000..8ec2023
--- /dev/null
+++ b/For Weekly Test/19-08-2011/GSM TMobile handler.log
@@ -0,0 +1,72 @@
+
+
+------------------STARTED THE LOGGING 2011-08-29 14:54:37.458067 ------------------
+On: 2011-08-29 14:54:37.458444 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 14:54:38.682624 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 46544)
+On: 2011-08-29 14:54:38.682979 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 14:54:38.683175 Event: RECEIVER READY SENT
+On: 2011-08-29 14:55:13.758373 Event: RECEIVE STATUS REPORTED
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:01:03.460167 ------------------
+On: 2011-08-29 15:01:03.460517 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 15:01:04.778102 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 36707)
+On: 2011-08-29 15:01:04.778466 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 15:01:04.778661 Event: RECEIVER READY SENT
+On: 2011-08-29 15:01:17.825938 Event: RECEIVE STATUS REPORTED
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:06:34.693265 ------------------
+On: 2011-08-29 15:06:34.693620 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 15:06:35.998526 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 46768)
+On: 2011-08-29 15:06:35.998892 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 15:06:35.999086 Event: RECEIVER READY SENT
+On: 2011-08-29 15:06:47.557887 Event: RECEIVE STATUS REPORTED
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:33:16.170754 ------------------
+On: 2011-08-29 15:33:16.171106 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 15:33:17.494565 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 53846)
+On: 2011-08-29 15:33:17.494931 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 15:33:17.495132 Event: RECEIVER READY SENT
+On: 2011-08-29 15:33:30.621930 Event: RECEIVE STATUS REPORTED
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:34:54.620572 ------------------
+On: 2011-08-29 15:34:54.620926 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 15:34:55.865065 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 53850)
+On: 2011-08-29 15:34:55.865431 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 15:34:55.865630 Event: RECEIVER READY SENT
+On: 2011-08-29 15:35:16.789899 Event: RECEIVE STATUS REPORTED
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:35:50.652397 ------------------
+On: 2011-08-29 15:35:50.652748 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 15:35:51.929928 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 53854)
+On: 2011-08-29 15:35:51.930293 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 15:35:51.930488 Event: RECEIVER READY SENT
+On: 2011-08-29 15:36:02.989940 Event: RECEIVE STATUS REPORTED
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:37:30.237841 ------------------
+On: 2011-08-29 15:37:30.238198 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 15:37:31.562584 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 40705)
+On: 2011-08-29 15:37:31.562949 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 15:37:31.563149 Event: RECEIVER READY SENT
+On: 2011-08-29 15:37:44.957902 Event: RECEIVE STATUS REPORTED
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:42:13.756431 ------------------
+On: 2011-08-29 15:42:13.756780 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 15:42:15.030575 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 49229)
+On: 2011-08-29 15:42:15.030941 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 15:42:15.031141 Event: RECEIVER READY SENT
+On: 2011-08-29 15:42:27.273913 Event: RECEIVE STATUS REPORTED
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:44:36.702649 ------------------
+On: 2011-08-29 15:44:36.703005 Event: LISTEN ON PORT: 50012
+On: 2011-08-29 15:44:37.988935 Event: CONNECTION ESTABLISHED AND DEVICE WORKING: ('127.0.0.1', 49243)
+On: 2011-08-29 15:44:37.989295 Event: TALK INITIALIZATION SENT
+On: 2011-08-29 15:44:37.989491 Event: RECEIVER READY SENT
+On: 2011-08-29 15:44:49.801896 Event: RECEIVE STATUS REPORTED
diff --git a/For Weekly Test/19-08-2011/University SIP handler.log b/For Weekly Test/19-08-2011/University SIP handler.log
new file mode 100644
index 0000000..df408ac
--- /dev/null
+++ b/For Weekly Test/19-08-2011/University SIP handler.log
@@ -0,0 +1,34 @@
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:04:55.756355 ------------------
+On: 2011-08-29 15:04:55.776952 Event: try to Connect to Controller
+On: 2011-08-29 15:04:57.054736 Event: init state
+On: 2011-08-29 15:04:57.054961 Event: Register Account to SIP server
+On: 2011-08-29 15:04:57.055378 Event: 100
+On: 2011-08-29 15:04:57.055462 Event: Receiver Handler Ready
+On: 2011-08-29 15:04:57.055761 Event: RECEIVE START
+On: 2011-08-29 15:05:00.086191 Event: {Call "mpselftest1" <sip:4661928@132.230.252.228>}
+On: 2011-08-29 15:05:00.086651 Event: Call Connecting
+On: 2011-08-29 15:05:00.086687 Event: 200
+On: 2011-08-29 15:05:00.086836 Event: Answer call
+On: 2011-08-29 15:05:00.086867 Event: Hangup call
+On: 2011-08-29 15:05:00.087024 Event: CALL OK
+On: 2011-08-29 15:05:00.142958 Event: Terminate
+On: 2011-08-29 15:05:00.143015 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-08-29 15:05:33.893338 ------------------
+On: 2011-08-29 15:05:33.914091 Event: try to Connect to Controller
+On: 2011-08-29 15:05:35.197825 Event: init state
+On: 2011-08-29 15:05:35.198095 Event: Register Account to SIP server
+On: 2011-08-29 15:05:35.198514 Event: 100
+On: 2011-08-29 15:05:35.198597 Event: Receiver Handler Ready
+On: 2011-08-29 15:05:35.198968 Event: RECEIVE START
+On: 2011-08-29 15:05:38.212991 Event: {Call "mpselftest1" <sip:4661928@132.230.252.228>}
+On: 2011-08-29 15:05:38.213458 Event: Call Connecting
+On: 2011-08-29 15:05:38.213496 Event: 200
+On: 2011-08-29 15:05:38.213639 Event: Answer call
+On: 2011-08-29 15:05:38.213671 Event: Hangup call
+On: 2011-08-29 15:05:38.213866 Event: CALL OK
+On: 2011-08-29 15:05:38.274410 Event: Terminate
+On: 2011-08-29 15:05:38.274475 Event: Goodbye
diff --git a/For Weekly Test/19-08-2011/inserttest.py b/For Weekly Test/19-08-2011/inserttest.py
new file mode 100644
index 0000000..3e75d46
--- /dev/null
+++ b/For Weekly Test/19-08-2011/inserttest.py
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import MySQLdb as mdb
+import sys
+
+try:
+ conn = mdb.connect('localhost', 'root', 'randompasswordSQL', 'gsmselftesting')
+
+ cursor = conn.cursor()
+
+ cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('1', '2', 'sip', 'GSMExt.O2', '0')")
+ cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('2', '2', 'sip', 'GSMExt.Voda', '0')")
+ cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('3', '2', 'sip', 'GSMExt.Tm', '0')")
+ cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('4', '2', 'sip', 'GSMExt.Eplus', '0')")
+
+ conn.commit()
+
+ cursor.close()
+ conn.close()
+
+except mdb.Error, e:
+
+ print "Error %d: %s" % (e.args[0],e.args[1])
+ sys.exit(1)
diff --git a/For Weekly Test/Old/07-07-2011/Controller-SecondType.py b/For Weekly Test/Old/07-07-2011/Controller-SecondType.py
new file mode 100644
index 0000000..31df36c
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/Controller-SecondType.py
@@ -0,0 +1,308 @@
+import sys
+import os
+import re
+import time
+import MySQLdb
+import subprocess
+
+
+import classClient #import class socket
+import classDb #import class db
+
+from time import sleep
+from datetime import datetime
+
+
+user = 'root'
+passw = 'randompasswordSQL' #default password we agree with this password before!
+host = 'localhost'
+dbname = 'gsmselftesting'
+
+stop = "False"
+status = ""
+dbSStatus = ""
+
+
+#function to ping
+def FuncPing(host):
+ ping_cmd = os.popen('ping '+ host + ' -c 1 -W 1').read()
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ if pingAlive != -1:
+ return 1
+ else:
+ return 0
+
+
+# One function for all test case
+
+def FuncTest(orig, origAdd, dest, destAdd, destNo):
+
+ global repeatTest
+ global portOrig
+ global resultOrig
+ global resultDest
+ global x
+ global y
+ portOrig = None
+ resultOrig= None
+ resultDest = None
+
+
+ repeatTest = ""
+
+ try:
+
+ if dest =="gsmBox1" or dest =="gsmBox2":
+
+ if dest =="gsmBox1":
+ portOrig = 50095
+
+ if dest =="gsmBox2":
+ portOrig = 50096
+
+ print "GSM server handler", x.connect()
+ x.sendData('hello server please wakeup the handler and be caller')
+
+ else:
+ # open SIP caller handler
+
+ command="--command=python " +orig
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(5)
+
+ if orig=="SIPCall.py":
+ portOrig = 50097
+
+ if orig=="gsmcall_.py":
+ portOrig = 50098
+
+ if orig == "landlineCall.py":
+ portOrig = 50099
+
+ if orig == "LocalSIPCall.py":
+ portOrig = 50100
+
+ #else: #mean external GSM
+ # print "have not yet define"
+ #portOrig = 50101
+
+ x = classClient.Connection(origAdd,portOrig)
+ print ""
+ print "Caller handler status:", x.connect()
+
+ x.sendData('hello Handler')
+
+ # wait respond from origin handler
+ while 1:
+ origHandler = x.receiveData()
+ if origHandler <> "":
+ break
+ #think about time out
+
+ if origHandler == "ready":
+ print "Caller handler ready"
+ print ""
+ try:
+ y = None
+ global portDest
+ portDest = None
+
+ if dest =="gsmBox1" or dest =="gsmBox2":
+
+ if dest =="gsmBox1":
+ portDest = 50102
+
+ if dest =="gsmBox2":
+ portDest = 50103
+
+ y = classClient.Connection(destAdd,portDest)
+ print "GSM handler", y.connect()
+ y.sendData('hello server please wakeup the handler and be receiver')
+
+ else:
+ command="--command=python " +dest
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(2)
+
+ if dest=="SIPIncoming.py":
+ portDest = 50104
+
+ if dest=="gsmincom_.py":
+ portDest = 50105
+
+ if dest == "landlineReceiver.py":
+ portDest = 50106
+
+ if dest == "LocalSIPReceiver.py":
+ portDest = 50107
+
+ #mean external GSM
+ #print "not define yet"
+ #portDest = 50108
+
+ y = classClient.Connection(destAdd,portDest)
+ print "Destination handler status:", y.connect()
+ y.sendData('hello Receiver, caller number')
+
+ #wait respond from destination handler
+ while 1:
+ destHandler = y.receiveData()
+ if destHandler <> "":
+ break
+ #should have timeout = think about timeout
+
+ if destHandler == "ready":
+
+ print "Destination handler ready"
+ print ""
+ x.sendData("start")#send message to handler to start the call
+ x.closeConnection()
+ x.connect()
+
+ #wait respond from both of handler
+ while 1:
+ sleep(5)
+ x.connect()
+ sleep(1)
+ resultOrig = x.receiveData()
+ resultDest = y.receiveData()
+
+ if resultOrig <> "" or resultDest <> "":
+ break
+
+ #if failed, try one more time
+ if resultOrig == "failed" or resultDest == "failed":
+ y.sendData('hello Destination Handler')
+ x.sendData("start")
+ sleep(2)
+ x.sendData(destNo)
+
+ while 1:
+ resultOrig = X.receiveData()
+ resultDest = y.receiveData()
+ print "Origin1: ", resultOrig
+ print "Destination1: ", resultDest
+
+ if resultOrig <> "" or resultDest <> "":
+ break
+
+ #if still failed, save to db and return repeat test, so we make automatic test vice versa
+ if resultOrig == "failed" or resultDest == "failed":
+ #db.execute ("update result table")
+ repeatTest="true"
+ print "Origin2: ", resultOrig
+ print "Destination1: ", resultDest
+
+ else: #save to database, tell handler to terminated
+ #db.execute ("update result table")
+ print "Test Result origin: ", resultOrig
+ print "Test Result Destination: ", resultDest
+ x.sendData('terminated') # signal caller to terminate
+ y.sendData('terminated') # signal receiver to terminate
+
+ else:
+ statusTest = "604 General Handler Error: Destination handler no respond"
+ #tell Caller handler to terminate because receiver doesnt work
+ x.sendData("terminated")
+
+ y.closeConnection()
+
+ except ValueError:
+ print "601 General Handler Error: Could not open Destination handler"
+ else:
+ statusTest = "605 General Handler Error: Origin handler no respond"
+
+ x.closeConnection()
+
+ except ValueError:
+ print "602 General Handler Error: Could not open Origin handler"
+
+
+
+# Main software
+
+
+
+# Check DB connection
+x = classDb.DBMySQLConnection(user, passw, host, dbname)
+print "connected to the DB ", x.connectDB()
+print ""
+dbStatus = x.connectDB()
+
+
+if dbStatus == 1:
+
+ # Check Ping to the Every Handler
+ #sipServerStatus = FuncPing("132.230.4.8")
+ sipServerStatus =1
+ #gsmBox1Status = FuncPing("132.230.4.8")
+ #gsmBox2Status = FuncPing("132.230.4.8")
+
+# Fetch The task information from DB
+ #print "do i have anything to do", x.anyTasksToDo()
+
+ #for item in x.tasksList:
+ # taskID = item[0]
+ # callFrom = item[1]
+ # callTo = item[2]
+ callFrom = "gsmrz1"
+ callTo = "sip"
+ #J = 1, 2
+ #for A in J:
+# print "call from to ", taskID , callFrom , callTo
+ print "Test Task : Calling from " +callFrom+ " to " +callTo
+ print ""
+
+
+ if callFrom == "sip" and sipServerStatus <> 0:
+
+ if callTo == "gsmrz1":
+
+ FuncTest("SIPCall.py", "localhost", "gsmincom_.py", "localhost","473")
+ print "Finish test"
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz2":
+
+ if gsmBox1Status <> 0:
+ FuncTest("SIPCall.py", "localhost", "Box1", "132.0.0.2","404")
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz3":
+
+ if gsmBox2Status <> 0:
+ FuncTest("SIPCall.py", "localhost", "Box2", "132.0.0.3","405")
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+
+ if callFrom =="gsmrz1":
+
+ if callTo =="sip" and sipServerStatus <> 0:
+ FuncTest("gsmcall_.py", "localhost", "SIPIncoming.py", "localhost","929")
+ sleep(10)
+
+
+ if callTo =="gsmrz2" and gsmBox1Status <> 0:
+ FuncTest("Box1", "132.0.0.2", "SIPReceiver.py", "localhost","929")
+
+ if callTo =="gsmrz3" and gsmBox2Status <> 0:
+ FuncTest("Box2", "132.0.0.3", "SIPReceiver.py", "localhost","929")
+
+
+
+
+# will exit if DB connection failed
+else:
+ sys.exit(5)
+
diff --git a/For Weekly Test/Old/07-07-2011/Controller-SecondType_withDB.py b/For Weekly Test/Old/07-07-2011/Controller-SecondType_withDB.py
new file mode 100644
index 0000000..a45fd05
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/Controller-SecondType_withDB.py
@@ -0,0 +1,339 @@
+import sys
+import os
+import re
+import time
+import MySQLdb
+import subprocess
+
+
+import classClient #import class socket
+import classDb #import class db
+import classPing
+
+from time import sleep
+from datetime import datetime
+
+
+user = 'root'
+passw = 'randompasswordSQL' #default password we agree with this password before!
+host = 'localhost'
+dbname = 'gsmselftesting'
+
+stop = "False"
+status = ""
+dbSStatus = ""
+
+sipNum = "4661929"
+landlnNum = "076145875681"
+
+
+sipCall = "sipCall.py"
+sipRec = "sipReceiver.py"
+landlnCall = "landlineCall.py"
+landlnRec = "landlineReceiver.py"
+localSipCall = "localsipCall.py"
+localSipRec = "localsipReceiver.py"
+rz1Call = "rz1Call.py"
+rz1Rec = "rz1Receiver.py
+
+o2Call = "o2Call.py"
+o2Rec = "o2Receiver.py"
+vodafoneCall = "vodafoneCall.py"
+vodafoneRec = "vodafoneReceiver.py"
+tmobileCall = "tmobileCall.py"
+tmobilRec = "tmobileReceiver.py"
+
+# One function for all test case
+
+def FuncTest(orig, origAdd, dest, destAdd, destNo):
+
+ global repeatTest
+ global portOrig
+ global resultOrig
+ global resultDest
+ global x
+ global y
+ portOrig = None
+ resultOrig= None
+ resultDest = None
+
+
+ repeatTest = ""
+
+ try:
+
+ if dest =="gsmBox1" or dest =="gsmBox2":
+
+ if dest =="gsmBox1":
+ portOrig = 50095
+
+ if dest =="gsmBox2":
+ portOrig = 50096
+
+ print "GSM server handler", x.connect()
+ x.sendData('hello server please wakeup the handler and be caller')
+
+ else:
+ # open SIP caller handler
+
+ command="--command=python " +orig
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(5)
+
+ if orig=="SIPCall.py":
+ portOrig = 50097
+
+ if orig=="gsmcall_.py":
+ portOrig = 50098
+
+ if orig == "landlineCall.py":
+ portOrig = 50099
+
+ if orig == "LocalSIPCall.py":
+ portOrig = 50100
+
+ #else: #mean external GSM
+ # print "have not yet define"
+ #portOrig = 50101
+
+ x = classClient.Connection(origAdd,portOrig)
+ print ""
+ print "Caller handler status:", x.connect()
+
+ x.sendData('hello Handler')
+
+ # wait respond from origin handler
+ while 1:
+ origHandler = x.receiveData()
+ if origHandler <> "":
+ break
+ #think about time out
+
+ if origHandler == "ready":
+ print "Caller handler ready"
+ print ""
+ try:
+ y = None
+ global portDest
+ portDest = None
+
+ if dest =="gsmBox1" or dest =="gsmBox2":
+
+ if dest =="gsmBox1":
+ portDest = 50102
+
+ if dest =="gsmBox2":
+ portDest = 50103
+
+ y = classClient.Connection(destAdd,portDest)
+ print "GSM handler", y.connect()
+ y.sendData('hello server please wakeup the handler and be receiver')
+
+ else:
+ command="--command=python " +dest
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(2)
+
+ if dest=="SIPIncoming.py":
+ portDest = 50104
+
+ if dest=="gsmincom_.py":
+ portDest = 50105
+
+ if dest == "landlineReceiver.py":
+ portDest = 50106
+
+ if dest == "LocalSIPReceiver.py":
+ portDest = 50107
+
+ #mean external GSM
+ #print "not define yet"
+ #portDest = 50108
+
+ y = classClient.Connection(destAdd,portDest)
+ print "Destination handler status:", y.connect()
+ y.sendData('hello Receiver, caller number')
+
+ #wait respond from destination handler
+ while 1:
+ destHandler = y.receiveData()
+ if destHandler <> "":
+ break
+ #should have timeout = think about timeout
+
+ if destHandler == "ready":
+
+ print "Destination handler ready"
+ print ""
+ x.sendData("start ")#send message to handler to start the call
+ sleep(1)
+ x.sendData(destNo)
+
+ #for refresh socket, so gsm handler can use socket to communicated with the phone
+ x.closeConnection()
+ x.connect()
+
+ #wait respond from both of handler
+ while 1:
+ sleep(5)
+ x.connect()
+ sleep(1)
+ resultOrig = x.receiveData()
+ resultDest = y.receiveData()
+
+ if resultOrig <> "" or resultDest <> "":
+ break
+
+ #if failed, try one more time
+ if resultOrig == "failed" or resultDest == "failed":
+ y.sendData('hello Destination Handler')
+ x.sendData("start")
+ sleep(2)
+ x.sendData(destNo)
+
+ #for refresh socket, so gsm handler can use socket to communicated with the phone
+ x.closeConnection()
+ x.connect()
+
+ while 1:
+ resultOrig = X.receiveData()
+ resultDest = y.receiveData()
+ print "Origin1: ", resultOrig
+ print "Destination1: ", resultDest
+
+ if resultOrig <> "" or resultDest <> "":
+ break
+
+ #if still failed, save to db and return repeat test, so we make automatic test vice versa
+ if resultOrig == "failed" or resultDest == "failed":
+ #db.execute ("update result table")
+ repeatTest="true"
+ print "Origin2: ", resultOrig
+ print "Destination1: ", resultDest
+
+ else: #save to database, tell handler to terminated
+ #db.execute ("update result table")
+ print "Test Result origin: ", resultOrig
+ print "Test Result Destination: ", resultDest
+ x.sendData('terminated') # signal caller to terminate
+ y.sendData('terminated') # signal receiver to terminate
+
+ else:
+ statusTest = "604 General Handler Error: Destination handler no respond"
+ #tell Caller handler to terminate because receiver doesnt work
+ x.sendData("terminated")
+
+ y.closeConnection()
+
+ except ValueError:
+ print "601 General Handler Error: Could not open Destination handler"
+ else:
+ statusTest = "605 General Handler Error: Origin handler no respond"
+
+ x.closeConnection()
+
+ except ValueError:
+ print "602 General Handler Error: Could not open Origin handler"
+
+
+
+# Main software
+
+
+
+# Check DB connection
+x = classDb.DBMySQLConnection(user, passw, host, dbname)
+print "connected to the DB ", x.connectDB()
+print ""
+dbStatus = x.connectDB()
+
+
+if dbStatus == 1:
+
+ # Check Ping to the Every Handler
+ sipServer = PingClass.Ping('132.230.4.60')
+ sipServerStatus = sipServer.ping(3)
+
+ sipGateServer = PingClass.Ping('sipgate.de')
+ sipGateServerStatus = sipGateServer.ping(3)
+
+ sipLocalServer = PingClass.Ping('132.230.4.60')
+ sipLocalServerStatus = sipLocalServer.ping(3)
+
+ #gsmBox1Status = FuncPing("132.230.4.8")
+ #gsmBox2Status = FuncPing("132.230.4.8")
+
+# Fetch The task information from DB
+ print "do i have anything to do", x.anyTasksToDo()
+
+ for item in x.tasksList:
+ taskID = item[0]
+ callFrom = item[1]
+ callTo = item[2]
+
+ print "call from to ", taskID , callFrom , callTo
+
+ if callFrom == "sip" and sipServerStatus <> 0:
+
+ if callTo == "gsmrz1":
+
+ FuncTest(sipCall, "localhost", "gsmincom_.py", "localhost","4661473")
+ print "Finish test"
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz2":
+
+ if gsmBox1Status <> 0:
+ FuncTest(sipCall, "localhost", "Box1", "132.0.0.2","404")
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz3":
+
+ if gsmBox2Status <> 0:
+ FuncTest(sipCall, "localhost", "Box2", "132.0.0.3","405")
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+ if callTo == "landline" and sipGateSeverStatus <> 0:
+ FuncTest(sipCall, "localhost", landlnRec, "localhost",landlnNum)
+
+ if callTo == "localsip" and sipLocalSeverStatus <> 0:
+ FuncTest(sipCall, "localhost", localSipRec, "localhost","405")
+
+ if callTo == "externalgsm":
+ FuncTest(sipCall, "localhost", o2Rec, "localhost","405")
+ FuncTest(sipCall, "localhost", tmobileRec, "localhost","405")
+ FuncTest(sipCall, "localhost", vodafoneRec, "localhost","405")
+ FuncTest(sipCall, "localhost", "xx", "localhost","405")
+
+
+
+ if callFrom =="gsmrz1":
+
+ if callTo =="sip" and sipServerStatus <> 0:
+ FuncTest("gsmcall_.py", "localhost", sipRec, "localhost",sipNum)
+ sleep(10)
+
+
+ if callTo =="gsmrz2" and gsmBox1Status <> 0:
+ FuncTest("Box1", "132.0.0.2", sipRec, "localhost",sipNum)
+
+ if callTo =="gsmrz3" and gsmBox2Status <> 0:
+ FuncTest("Box2", "132.0.0.3", sipRec, "localhost",sipNum)
+
+
+
+
+# will exit if DB connection failed
+else:
+ sys.exit(5)
+
diff --git a/For Weekly Test/Old/07-07-2011/ca_stMa.py b/For Weekly Test/Old/07-07-2011/ca_stMa.py
new file mode 100644
index 0000000..5df33c8
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/ca_stMa.py
@@ -0,0 +1,153 @@
+from serial import * #serial port library
+from threading import Thread #library to make a thread (I guess)
+from time import sleep #timer library
+import string #import the string handling library
+import sys
+import atexit
+import signal
+
+####START of the definition how the serial port works
+
+class TimeoutException(Exception):
+ pass
+
+def serial_portFunc():
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(50) # triger alarm in 50 seconds
+
+ try:
+ global last_received #make last_received a global variable
+ global exitSuccessful
+ portAddress = '/dev/ttyUSB0'
+ portName = portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE
+ #timeout=0,
+ #writeTimeout=0
+ #xonxoff=0,
+ #rtscts=0
+ #interCharTimeout=None
+ #I didn't need to set these variables :)
+ )
+ ####END of the definition how the serial port works
+ exitSuccessful = 0 #variable used to know if it closed successfully
+
+ last_received = '' #reset the last received variable
+ global pickUp
+ pickUp = 0
+ ser.write('AT\r') #just communicate with the cellphone at start
+ callTrue=0 #use this variable to make sure the cell phone has dialed a number
+ pickUp =0 #use to test if I pick up the call
+ firstCall = 1
+ firstCallSuccessful=0
+ buffer = '' #make sure buffer variable is empty
+ for arg in sys.argv:
+ callThisNumberFirst = arg
+ while True: #repeat the message accepting part forever
+
+
+ #####BEGIN part responsible for receiving on serial port
+
+ buffer = buffer + ser.read(ser.inWaiting()) #read the serial port and add it to the buffer variable
+ if '\n' in buffer: #if a new line character is found in the buffer then the cellphone has sent something
+ lines = buffer.split('\n') #parse the buffer variable with the new line character
+ last_received = lines.pop(0) #put into last_received variable the first content from lines (FIFO)
+
+ buffer = '\n'.join(lines) #add a new line to the buffer variable
+
+ last_received=last_received.split('\n') #parse the last received value with new lines
+ line = last_received[0].replace(chr(13), '') #remove \r from the first parsed value in last_received and return me a nicely parsed value :)
+ #print line;
+
+ #####END part responsible for receiving on serial port
+
+
+
+
+
+
+ #####START of the state machine responsible for talking to the cellphone
+
+ if len(line) > 0: #if line not empty then it is a value the cellphone returned
+ #print 'I received:',line, len(line)
+ if firstCall==1:
+ #print 'I AM IN THE IF :)'
+ sleep(1)
+ callThisNumberFirst = 'ATD'+callThisNumberFirst+';\r'
+ ser.write(callThisNumberFirst) #call the number from the argument
+ line=''
+
+ #sleep(5)
+ #ser.write('AT+CSQ\r') #send the command for signal strength
+ #sleep(2)
+ ##sleep(5) #sleep 2 seconds
+ #ser.write('AT+CHUP\r')
+ firstCall=0
+ firstCallSuccessful=1
+
+ if (line=='OK') and (firstCallSuccessful==1):
+ #print 'Successfully connected'
+ sleep(1)
+ ser.write('AT+CSQ\r') #send the command for signal strength
+ sleep(5)
+ #sleep(5) #sleep 2 seconds
+ sleep(1)
+ ser.write('AT+CHUP\r')
+ firstCallSuccessful=0
+ line = ''
+
+ if line=='RING': #the cellphone is ringing and somebody is calling
+ if pickUp == 0:
+ sleep(1)
+ ser.write('ATA\r') #pick up the phone call
+ sleep(0.5) #wait half a second before sending another AT command
+ sleep(1)
+ ser.write('AT+CSQ\r') #tell me the signal quality command
+ sleep(3)
+ sleep(1)
+ ser.write('AT+CHUP\r') #ask for the callers numbers
+ line=''
+ pickUp=1
+
+ if line[0:5] == '+CSQ:':
+ space = int(string.find(line,' '))+1 #find the (space) sign
+ coma = int(string.find(line,',')) #find the , (coma) sign
+ signalStrength = (int(line[space:coma])*2)-113
+ #print 'Signal strength', signalStrength, 'dBm'
+ line=''
+ if pickUp==1:
+ exitSuccessful = 1
+ return '|1|'+str(signalStrength)+'|'
+
+ if len(line) == 4:
+ if line == 'BUSY':
+ if callTrue == 1:
+ signalStr = '|0|Number was busy|'
+ return '|0|Number was busy|'
+
+ #####END of the state machine responsible for talking to the cellphone
+ except TimeoutException:
+ return "|2|Timeout"
+ finally:
+ signal.signal(signal.SIGALRM, old_handler)
+
+ signal.alarm(0)
+ return signalStr
+
+if __name__ == '__main__':
+ result = serial_portFunc()
+ print result
+
diff --git a/For Weekly Test/Old/07-07-2011/classClient.py b/For Weekly Test/Old/07-07-2011/classClient.py
new file mode 100644
index 0000000..ce02d19
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/classClient.py
@@ -0,0 +1,66 @@
+import socket
+import sys
+import os
+import string
+
+class Connection:
+ def __init__(self, h, p):
+ self.host = h
+ self.port = p
+ self.s = None
+ self.connected = 0
+
+ def connect(self):
+ self.s = None
+
+ alive = self.ping()
+ if alive == 0:
+ return 'The machine is not alive'
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM):
+ af, socktype, proto, canonname, sa = res
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ continue
+ try:
+ self.s.connect(sa)
+ except socket.error, msg:
+ self.s.close()
+ self.connected = 0
+ self.s = None
+ continue
+ break
+ if self.s is None:
+ self.connected = 0
+ return 'Could not open socket'
+ else:
+ self.connected = 1
+ return 'Connected'
+
+ def sendData(self, data):
+ if self.connected == 1:
+ self.s.send(data)
+
+ def receiveData(self):
+ if self.connected == 1:
+ return self.s.recv(1024)
+ else:
+ return 'Not connected'
+
+ def closeConnection(self):
+ if self.connected == 1:
+ self.s.close()
+ self.connected = 0
+ return 'Closed'
+
+ def ping(self):
+ ping_cmd = os.popen('ping '+ self.host + ' -c 1 -W 1').read()
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ if pingAlive != -1:
+ return 1
+ else:
+ return 0
+
diff --git a/For Weekly Test/Old/07-07-2011/classClient.pyc b/For Weekly Test/Old/07-07-2011/classClient.pyc
new file mode 100644
index 0000000..b93c110
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/classClient.pyc
Binary files differ
diff --git a/For Weekly Test/Old/07-07-2011/classDb.py b/For Weekly Test/Old/07-07-2011/classDb.py
new file mode 100644
index 0000000..615b868
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/classDb.py
@@ -0,0 +1,212 @@
+import MySQLdb
+import string
+
+class DBMySQLConnection:
+ def __init__(self, username, password, host, dbname):
+ #initialize at the start all the user parameters
+ self.usern = username
+ self.passw = password
+ self.host = host
+ self.db = dbname
+ self.connectionCreated = 0
+ self.tasksList = list()
+ global debugMode
+ debugMode = 0
+
+ def connectDB(self):
+ try:
+ #try the connection
+ self.datBaseConn=MySQLdb.connect(self.host,self.usern, self.passw,self.db)
+ self.datBaseConn.paramstyle = 'format'
+ self.cur = self.datBaseConn.cursor() #make the cursor, used for sending queries
+ self.connectionCreated = 1 #use it as an indicator that the connection was created
+ return 1
+
+ except MySQLdb.Error, e:
+ #if we have an error then try to catch it
+ error=str(e)
+ if error[1:5] == '1045':
+ #wrong username or password
+ return 0
+ elif error[1:5] == '2002':
+ #can't connect to mysql, mysql shutdown or wrong host
+ return 2
+ else:
+ if debugMode == 1:
+ print error
+ return 3
+
+ def closeDBConn(self):
+ #close the connection to the database here
+ if self.connectionCreated == 1:
+ try:
+ #close the cursor and then the connection to the DB
+ self.cur.close()
+ self.datBaseConn.close()
+ return 1
+ except MySQLdb.Error, e:
+ #in case of an error
+ if debugMode == 1:
+ error = str(e)
+ print error
+ return 3
+ else:
+ #I never really had a connection
+ return 0
+
+ def anyTasksToDo(self):
+ #see are there any jobs to be executed and make a list out of it
+ if self.connectionCreated == 1:
+ try:
+ self.cur.execute("SELECT * FROM TempTaskTable")
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+ for record in output:
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+ self.tasksList.append(columns)
+ return 1
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def cleanTasksList(self):
+ if self.connectionCreated == 1:
+ del self.tasksList[:]
+ return 1
+ else:
+ return 0
+
+ def removeTaskFromList(self, taskID):
+ #remove only one task from the task list
+ if self.connectionCreated == 1:
+ for index in range(len(self.tasksList)):
+ item = self.tasksList[index]
+ if item[0] == str(taskID):
+ #self.tasksList.remove(index)
+ #print 'found it'
+ del self.tasksList[index]
+ return 1 #deleted taskID
+
+ return 2 #didn't find that taskID
+ else:
+ return 0
+
+ def deviceAddress(self,deviceName):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("SELECT `deviceIP` FROM DeviceAddress where `deviceName`=%s", deviceName)
+ #self.cur.execute()
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+ deviceAddr = ''
+ for record in output:
+ columns = list()
+ for entry in record:
+ deviceAddr = str(entry)
+ return deviceAddr
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3 #some error happened
+ else:
+ return 0 #I am not connected
+
+ def updateTaskResult(self, taskID, status):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE TaskTable SET status=%i WHERE taskID=%i"%(int(status), int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #update successful
+ else:
+ return 4 #taskID doesn't exist
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def updatePingResult(self, taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE PingResultTable SET sipServer=%i, sipGate=%i, sipLoc=%i, gsmBox1=%i, gsmBox2=%i WHERE taskNo=%i"%(int(sipServer), int(sipGate), int(sipLoc), int(gsmBox1), int(gsmBox2), int(taskNo)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #ping table updated
+ else:
+ return 4 #the taskNo didn't exist
+
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def deleteTempTask(self, taskID):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("DELETE FROM TempTaskTable WHERE taskID=%i"%(int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+
+ if successful == 1:
+ return 1 #deleted it
+ else:
+ return 4 #that taskID didn't exist or something else
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+
+ else:
+ return 0
+
+ def addResult(self, taskID, result):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("INSERT INTO ResultTable(taskID, result) VALUES ('%i', '%i')"%(int(taskID), int(result)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 1:
+ return 1 #successfully added the result
+ else:
+ return 4 #hmmm
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1062':
+ return 2 #duplicate entry for the key
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
diff --git a/For Weekly Test/Old/07-07-2011/classDb.pyc b/For Weekly Test/Old/07-07-2011/classDb.pyc
new file mode 100644
index 0000000..92d31c6
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/classDb.pyc
Binary files differ
diff --git a/For Weekly Test/Old/07-07-2011/classPing.py b/For Weekly Test/Old/07-07-2011/classPing.py
new file mode 100644
index 0000000..e13b32b
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/classPing.py
@@ -0,0 +1,28 @@
+import subprocess
+import string
+
+class Ping:
+
+ def __init__(self, pingAddress):
+ self.pingAddress = pingAddress
+
+ def ping(self,numberTries):
+ tried = 1
+ while numberTries >= tried:
+ tried += 1
+ #the parameter c 1 means only one ping to be sent, parameter W 3 means how many seconds the time out should be, 3 seconds
+ ping_cmd = subprocess.Popen(['ping', self.pingAddress, '-c', '1', '-W', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ unknownHost = int(string.find(ping_cmd, 'unknown host'))
+
+
+ if pingAlive != -1:
+ break
+
+ if unknownHost != -1:
+ return 2 #unknown host
+ if pingAlive != -1:
+ return 1 #ping works fine
+ else:
+ return 0 #no ping response
diff --git a/For Weekly Test/Old/07-07-2011/classServer.py b/For Weekly Test/Old/07-07-2011/classServer.py
new file mode 100644
index 0000000..97a398d
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/classServer.py
@@ -0,0 +1,94 @@
+# Echo server program
+import socket
+import sys
+import os
+import string
+from time import sleep
+
+class ServerHandler:
+
+ def __init__(self,p):
+ self.port = p
+ self.host = None #symbolic name meaning all available interfaces
+ self.s = None
+ self.connected = 0
+ self.address = "127.0.0.1" #address of the main controller
+ self.onceConnected = 0
+ self.error = 'No error'
+
+ def openSocket(self):
+ self.error = 'No error'
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC,
+ socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
+ af, socktype, proto, canonname, sa = res
+
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+
+ try:
+ self.s.bind(sa)
+ self.s.listen(1)
+ except socket.error, msg:
+ self.s.close()
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+ break
+
+ if self.s is None:
+ self.connected = 0
+ return 0
+ else: #accept the connection
+ self.connection, self.address = self.s.accept()
+ self.connected = 1
+ self.onceConnected = 1
+ return 1
+
+ def connectedTo(self):
+ return self.address
+
+ def receiveData(self):
+ if self.connected == 1:
+ while 1:
+ data = self.connection.recv(64)
+ if not data:
+ return 'NO DATA'
+ else:
+ return data
+ else:
+ return 0
+
+ def sendData(self, data):
+ if self.connected == 1:
+ self.connection.send(data)
+ return 1
+ else:
+ return 0
+
+ def closeConnection(self):
+ if self.onceConnected == 1:
+ self.connection.close()
+ self.s.close()
+ self.s = None
+ self.connected == 0
+ return 1
+ else:
+ return 0
+
+ def killPort(self):
+ killResult = os.popen('lsof -i tcp:' + str(self.port) + ' | grep "python " | awk -F" " ' + "'{print $2}'").read()
+ killResult = killResult.replace('\n','')
+ print killResult
+ if killResult!='':
+ print killResult
+ killPort = os.popen("kill -9 " + killResult).read()
+ return 1
+ return 0
+
diff --git a/For Weekly Test/Old/07-07-2011/classServer.pyc b/For Weekly Test/Old/07-07-2011/classServer.pyc
new file mode 100644
index 0000000..52f5085
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/classServer.pyc
Binary files differ
diff --git a/For Weekly Test/Old/07-07-2011/gsmcall2_.py b/For Weekly Test/Old/07-07-2011/gsmcall2_.py
new file mode 100644
index 0000000..bf8e662
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/gsmcall2_.py
@@ -0,0 +1,102 @@
+import sys
+import pjsua as pj
+import socket
+import time
+
+import subprocess
+import os
+from serial import *
+
+import classServer
+
+from time import sleep
+from datetime import datetime
+import string
+
+
+stop ="false"
+success = "failed"
+
+
+try:
+ global ser
+ portAddress = '/dev/ttyUSB0'
+ portName = portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+
+ ser.open()
+
+ server = classServer.ServerHandler(50098)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ server.sendData('ready')#send message to controller
+ print "Status Server:", server.connected
+ print ""
+
+ while stop <> "true":
+ try:
+ data = server.receiveData() # waiting mode, until receiver start message or terminate message
+ ser.write('AT+CSQ\r')
+ signalQuality = ser.read(35)
+ print "Signal Bar: ", signalQuality
+ #
+
+
+ if data == "start": # if receiver start message, handler start to call destination
+ while 1:
+
+ num = server.receiveData() # waiting destination number
+
+ #num = 929
+
+ if num <> "":
+
+ ser.write('ATD' + num + ';\r')
+ sleep(5)
+ success = "success"
+ server.sendData(success)
+ ser.write('AT+CHUP\r')
+
+ break
+
+ if data == "terminated": # will terminate the handler if controller send terminate message
+ stop = "true"
+ break
+
+ except ValueError:
+ print "error on calling mode"
+ server.closeConnection()
+ del server
+
+
+
+ server.sendData(success)
+ server.closeConnection()
+ ser.close()
+ del server
+
+except ValueError:
+ print "Exception: "
+
+print "Goodbye"
+sleep(3)
diff --git a/For Weekly Test/Old/07-07-2011/gsmcall_.py b/For Weekly Test/Old/07-07-2011/gsmcall_.py
new file mode 100644
index 0000000..039622c
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/gsmcall_.py
@@ -0,0 +1,105 @@
+import sys
+import socket
+import time
+
+import subprocess
+import os
+from serial import *
+
+import classServer
+
+from time import sleep
+import string
+
+
+stop ="false"
+success = "failed"
+
+global server
+
+global ser
+portAddress = '/dev/ttyUSB1'
+portName = portAddress[-4:]
+portExist = os.popen('dmesg | grep ' + portName).read()
+
+if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+
+
+while stop <> "true":#???
+
+
+ try:
+
+ server = classServer.ServerHandler(50098)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ server.sendData('ready')#send message to controller
+ print "Controller status: ", server.connected
+
+
+ while stop <> "true":
+ try:
+ data = server.receiveData() # waiting mode, until receiver start message or terminate message
+
+ if data == "start": # if receiver start message, handler start to call destination
+
+ while 1:
+
+ num = server.receiveData()
+
+ #num = "929"
+ if num <> "NO DATA":
+ server.closeConnection()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+ ser.close()
+ ser.open()
+
+ ser.write('ATD4661' + num + ';\r')
+ sleep(3)
+ ser.write('AT+CHUP\r')
+
+ ser.close()
+ tried = server.openSocket()
+ sleep(2)
+ success = "success"
+ server.sendData(success)
+
+ if data == "terminated": # will terminate the handler if controller send terminate message
+ stop = "true"
+ break
+
+ except ValueError:
+ print "error when sending message"
+ server.closeConnection()
+ del server
+
+
+ server.closeConnection()
+ del server
+ print "Goodbye"
+ sleep(3)
+ sys.exit(1)
+
+ except ValueError:
+ print "Exception: " + str(e)
+
+print "Goodbye"
+sleep(3)
diff --git a/For Weekly Test/Old/07-07-2011/gsmincom_.py b/For Weekly Test/Old/07-07-2011/gsmincom_.py
new file mode 100644
index 0000000..a49c24c
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/gsmincom_.py
@@ -0,0 +1,155 @@
+
+import atexit
+import signal
+
+import sys
+import socket
+import time
+import os
+import string
+import classServer
+from time import sleep
+from serial import *
+
+
+success = None
+stop = False
+
+try:
+
+ global ser
+ global server
+ portAddress = '/dev/ttyUSB0'
+ portName = portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+
+
+ server = classServer.ServerHandler(50105)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ print "here:", server.connected
+ if server.connected == 1:
+
+ server.sendData('ready')
+ server.closeConection()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+ ser.close()
+ ser.open()
+
+ signalQuality = ser.write('AT+CSQ\r')
+ print "signal Quality ", signalQuality
+ print ""
+
+
+
+ while stop <> True:
+
+ global pickUp
+ pickUp = None
+ buffer = ""
+
+
+ buffer = buffer + ser.read(ser.inWaiting()) #read the serial port and add it to the buffer variable
+ if '\n' in buffer: #if a new line character is found in the buffer then the cellphone has sent something
+ lines = buffer.split('\n') #parse the buffer variable with the new line character
+ last_received = lines.pop(0) #put into last_received variable the first content from lines (FIFO)
+
+ buffer = '\n'.join(lines) #add a new line to the buffer variable
+
+ last_received=last_received.split('\n') #parse the last received value with new lines
+ line = last_received[0].replace(chr(13), '')
+
+ print "buffer:", buffer
+ print "line:", line
+
+ if len(line) > 0:
+
+
+ if line=="RING":
+
+ print "Somebody calling"
+ print ""
+ sleep(1)
+ ser.write('ATA\r')
+ sleep(1)
+ ser.write('AT+CSQ\r')
+
+ sleep(2)
+ ser.write('AT+CLCC\r')
+
+
+ if line[0:5] == '+CSQ:':
+
+ space = int(string.find(line,' '))+1
+ coma = int(string.find(line,','))
+ signalStr = (int(line[space:coma])*2)-113
+
+ line=''
+
+ if line[0:6]=='+CLCC:':
+
+ pickUp = 1
+
+ print "I will hangup the call"
+ print ""
+ sleep(5)
+
+ ser.write('AT+CHUP\r')
+ pickUp = 0
+ ser.close()
+
+ quotation1 = int(string.find(line,'"'))+1
+ lineTemp = line[quotation1:]
+
+ quotation2 = int(string.find(lineTemp,'"'))
+ numberOfCaller = line[quotation1:quotation1+quotation2]
+
+ print "Signal Strength: ", signalStr
+ print ""
+
+ tried = server.openSocket()
+ server.sendData('I got call from :' +numberOfCaller)
+ print "with caller number", numberOfCaller
+ sleep(1)
+ server.sendData('success')
+ stop = True
+ sleep (3)
+
+
+
+ server.closeConnection()
+ del server
+ else:
+
+ print "not connected"
+
+ del server
+
+ ser.close()
+except ValueError:
+ print "Exception: "
+ server.closeConnection()
+ del server
+
+print "GOODBYE"
+sleep(5)
diff --git a/For Weekly Test/Old/07-07-2011/sipCall.py b/For Weekly Test/Old/07-07-2011/sipCall.py
new file mode 100644
index 0000000..eb44b4a
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/sipCall.py
@@ -0,0 +1,176 @@
+import sys
+import pjsua as pj
+import socket
+import time
+import MySQLdb
+import subprocess
+
+import classServer
+
+from time import sleep
+from datetime import datetime
+import string
+
+
+stop ="false"
+server = "132.230.4.8"
+username = "mpselftest1"
+password = "1mpselftest"
+
+LOG_LEVEL=2
+current_call = None
+success = ""
+
+
+# Logging callback
+def log_cb(level, str, len):
+ print str, "SIP log"
+
+
+# Callback to receive events from account
+class MyAccountCallback(pj.AccountCallback):
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+ # Notification on incoming call##
+
+
+
+# Callback to receive events from Call
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+ # Notification when call state has changed
+ def on_state(self):
+ global current_call
+ global success
+
+ if self.call.info().state_text <> "DISCONNCTD":
+ if self.call.info().state_text == "CONNECTING":
+ print "CONNECTING CALL"
+ #print "isine opo:", self.call.info().state_text
+ print "CALL CONFIRMED and ESTABLISH", self.call.info().state_text
+ sleep(5)
+ current_call.hangup()
+ success = "true"
+ server.sendData(success)
+ else:
+ sleep(1)
+ #print ""
+
+ if self.call.info().last_reason <> "":
+
+ if self.call.info().last_reason == "Busy Here":
+
+ print "Destination Number is Busy or offline"
+ print ""
+ success = "false"
+ server.sendData(success)
+
+
+ #print self.call.info().state_text
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+ print 'Current call Disconnected'
+
+
+def make_call(uri):
+ try:
+ print "Making call to", uri
+ cb=MyCallCallback()
+ return acc.make_call(uri, cb)
+ except pj.Error, e:
+ print "Exception: " + str(e)
+ return None
+
+
+
+
+lib = pj.Lib()
+while stop <> "true":
+
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+ lib.start()
+ lib.set_null_snd_dev()
+
+ # open socket connection and connect to the controller
+ server = classServer.ServerHandler(50097)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+ try:
+ acc_cfg = pj.AccountConfig("132.230.4.8","mpselftest1","1mpselftest")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+ print my_sip_uri
+ server.sendData('ready')#send message to controller
+ print "here:", server.connected
+ while 1:
+ try:
+ data = server.receiveData() # waiting mode, until receiver start message or terminate message
+
+ if data == "start": # if receiver start message, handler start to call destination
+
+ while 1:
+
+ num = server.receiveData() # waiting destination number
+ if num <> "":
+
+ number = "sip:"+num+"@132.230.4.8"
+ current_call = make_call(number)
+ break
+
+ if data == "terminated": # will terminate the handler if controller send terminate message
+ stop = "true"
+ break
+
+ except ValueError:
+ print "error when sending message"
+ server.closeConnection()
+ del server
+
+ server.closeConnection()
+ del server
+
+ else:
+ Regis_status= "Bad"
+ print "error when register"
+
+ lib.destroy()
+ lib = None
+ acc = None
+
+
+ server.closeConnection()
+ del server
+ except ValueError:
+ print "Exception: " + str(e)
+
+print "Goodbye"
+sleep(3)
+acc.delete()
+lib.destroy()
+server.closeConnection()
+del server
+lib = None
+acc = None
+
diff --git a/For Weekly Test/Old/07-07-2011/sipReceiver.py b/For Weekly Test/Old/07-07-2011/sipReceiver.py
new file mode 100644
index 0000000..6404f10
--- /dev/null
+++ b/For Weekly Test/Old/07-07-2011/sipReceiver.py
@@ -0,0 +1,177 @@
+import sys
+import pjsua as pj
+import socket
+import time
+import os
+import string
+import classServer
+
+from time import sleep
+from datetime import datetime
+
+stop ="false"
+server = "132.230.4.8"
+username = "mpselftest2"
+password = "2mpselftest"
+
+LOG_LEVEL=2
+current_call = None
+success = ""
+global accept
+accept = None
+
+
+# Logging callback
+def log_cb(level, str, len):
+ print str, "I am here"
+
+
+# Callback to receive events from account
+class MyAccountCallback(pj.AccountCallback):
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+ # Notification on incoming call
+ def on_incoming_call(self, call):
+ global current_call
+ global number
+ if current_call:
+ call.answer(486, "Busy")
+ return
+
+ number = call.info().remote_uri
+
+ current_call = call
+
+ call_cb = MyCallCallback(current_call)
+ current_call.set_callback(call_cb)
+
+ current_call.answer(180)
+ print "accept call"
+ if current_call <> None:
+ accept = True
+ if accept == True:
+ sleep(2)
+ current_call.answer(200)
+ sleep(3)
+ current_call.hangup()
+ accept = "true"
+ server.sendData('success')
+
+ #server.sendData(success)
+
+
+
+
+
+# Callback to receive events from Call
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+ # Notification when call state has changed
+ def on_state(self):
+ global current_call
+
+ if self.call.info().state_text == "CONNECTING":
+ print self.call.info().state_text
+ success = "success"
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+ print 'Current call is', current_call
+
+ # Notification when call's media state has changed.
+ def on_media_state(self):
+ if self.call.info().media_state == pj.MediaState.ACTIVE:
+ # Connect the call to sound device
+ call_slot = self.call.info().conf_slot
+ pj.Lib.instance().conf_connect(call_slot, 0)
+ pj.Lib.instance().conf_connect(0, call_slot)
+ #server.sendData('establish connection')
+
+ print "Media is now active"
+
+
+ else:
+ print "Media is inactive"
+
+
+
+lib = pj.Lib()
+
+try:
+ #open socket connection to the controller
+ server = classServer.ServerHandler(50104)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+
+
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+
+ # Start the library
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+ # Create local account
+ acc_cfg = pj.AccountConfig("132.230.4.8", "mpselftest2", "2mpselftest")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+
+ server.sendData('ready')#send message to controller that the handler ready
+
+ while stop <> "true":
+
+ data = server.receiveData()#waiting message from controller
+ if data == "terminated":
+ break
+
+ if current_call == None:
+ accept = None
+ continue
+ else:
+ print "Incoming call from :", number
+
+ sleep(4)
+
+
+ # Shutdown the library
+ transport = None
+ acc.delete()
+ acc = None
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ del server
+ else:
+ Regis_status= "Bad"
+ print "error when register"
+
+ lib.destroy()
+ lib = None
+ acc = None
+ server.closeConnection()
+ del server
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ del server
diff --git a/For Weekly Test/Old/15-07-2011/Controller-SecondType.py b/For Weekly Test/Old/15-07-2011/Controller-SecondType.py
new file mode 100644
index 0000000..31df36c
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/Controller-SecondType.py
@@ -0,0 +1,308 @@
+import sys
+import os
+import re
+import time
+import MySQLdb
+import subprocess
+
+
+import classClient #import class socket
+import classDb #import class db
+
+from time import sleep
+from datetime import datetime
+
+
+user = 'root'
+passw = 'randompasswordSQL' #default password we agree with this password before!
+host = 'localhost'
+dbname = 'gsmselftesting'
+
+stop = "False"
+status = ""
+dbSStatus = ""
+
+
+#function to ping
+def FuncPing(host):
+ ping_cmd = os.popen('ping '+ host + ' -c 1 -W 1').read()
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ if pingAlive != -1:
+ return 1
+ else:
+ return 0
+
+
+# One function for all test case
+
+def FuncTest(orig, origAdd, dest, destAdd, destNo):
+
+ global repeatTest
+ global portOrig
+ global resultOrig
+ global resultDest
+ global x
+ global y
+ portOrig = None
+ resultOrig= None
+ resultDest = None
+
+
+ repeatTest = ""
+
+ try:
+
+ if dest =="gsmBox1" or dest =="gsmBox2":
+
+ if dest =="gsmBox1":
+ portOrig = 50095
+
+ if dest =="gsmBox2":
+ portOrig = 50096
+
+ print "GSM server handler", x.connect()
+ x.sendData('hello server please wakeup the handler and be caller')
+
+ else:
+ # open SIP caller handler
+
+ command="--command=python " +orig
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(5)
+
+ if orig=="SIPCall.py":
+ portOrig = 50097
+
+ if orig=="gsmcall_.py":
+ portOrig = 50098
+
+ if orig == "landlineCall.py":
+ portOrig = 50099
+
+ if orig == "LocalSIPCall.py":
+ portOrig = 50100
+
+ #else: #mean external GSM
+ # print "have not yet define"
+ #portOrig = 50101
+
+ x = classClient.Connection(origAdd,portOrig)
+ print ""
+ print "Caller handler status:", x.connect()
+
+ x.sendData('hello Handler')
+
+ # wait respond from origin handler
+ while 1:
+ origHandler = x.receiveData()
+ if origHandler <> "":
+ break
+ #think about time out
+
+ if origHandler == "ready":
+ print "Caller handler ready"
+ print ""
+ try:
+ y = None
+ global portDest
+ portDest = None
+
+ if dest =="gsmBox1" or dest =="gsmBox2":
+
+ if dest =="gsmBox1":
+ portDest = 50102
+
+ if dest =="gsmBox2":
+ portDest = 50103
+
+ y = classClient.Connection(destAdd,portDest)
+ print "GSM handler", y.connect()
+ y.sendData('hello server please wakeup the handler and be receiver')
+
+ else:
+ command="--command=python " +dest
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(2)
+
+ if dest=="SIPIncoming.py":
+ portDest = 50104
+
+ if dest=="gsmincom_.py":
+ portDest = 50105
+
+ if dest == "landlineReceiver.py":
+ portDest = 50106
+
+ if dest == "LocalSIPReceiver.py":
+ portDest = 50107
+
+ #mean external GSM
+ #print "not define yet"
+ #portDest = 50108
+
+ y = classClient.Connection(destAdd,portDest)
+ print "Destination handler status:", y.connect()
+ y.sendData('hello Receiver, caller number')
+
+ #wait respond from destination handler
+ while 1:
+ destHandler = y.receiveData()
+ if destHandler <> "":
+ break
+ #should have timeout = think about timeout
+
+ if destHandler == "ready":
+
+ print "Destination handler ready"
+ print ""
+ x.sendData("start")#send message to handler to start the call
+ x.closeConnection()
+ x.connect()
+
+ #wait respond from both of handler
+ while 1:
+ sleep(5)
+ x.connect()
+ sleep(1)
+ resultOrig = x.receiveData()
+ resultDest = y.receiveData()
+
+ if resultOrig <> "" or resultDest <> "":
+ break
+
+ #if failed, try one more time
+ if resultOrig == "failed" or resultDest == "failed":
+ y.sendData('hello Destination Handler')
+ x.sendData("start")
+ sleep(2)
+ x.sendData(destNo)
+
+ while 1:
+ resultOrig = X.receiveData()
+ resultDest = y.receiveData()
+ print "Origin1: ", resultOrig
+ print "Destination1: ", resultDest
+
+ if resultOrig <> "" or resultDest <> "":
+ break
+
+ #if still failed, save to db and return repeat test, so we make automatic test vice versa
+ if resultOrig == "failed" or resultDest == "failed":
+ #db.execute ("update result table")
+ repeatTest="true"
+ print "Origin2: ", resultOrig
+ print "Destination1: ", resultDest
+
+ else: #save to database, tell handler to terminated
+ #db.execute ("update result table")
+ print "Test Result origin: ", resultOrig
+ print "Test Result Destination: ", resultDest
+ x.sendData('terminated') # signal caller to terminate
+ y.sendData('terminated') # signal receiver to terminate
+
+ else:
+ statusTest = "604 General Handler Error: Destination handler no respond"
+ #tell Caller handler to terminate because receiver doesnt work
+ x.sendData("terminated")
+
+ y.closeConnection()
+
+ except ValueError:
+ print "601 General Handler Error: Could not open Destination handler"
+ else:
+ statusTest = "605 General Handler Error: Origin handler no respond"
+
+ x.closeConnection()
+
+ except ValueError:
+ print "602 General Handler Error: Could not open Origin handler"
+
+
+
+# Main software
+
+
+
+# Check DB connection
+x = classDb.DBMySQLConnection(user, passw, host, dbname)
+print "connected to the DB ", x.connectDB()
+print ""
+dbStatus = x.connectDB()
+
+
+if dbStatus == 1:
+
+ # Check Ping to the Every Handler
+ #sipServerStatus = FuncPing("132.230.4.8")
+ sipServerStatus =1
+ #gsmBox1Status = FuncPing("132.230.4.8")
+ #gsmBox2Status = FuncPing("132.230.4.8")
+
+# Fetch The task information from DB
+ #print "do i have anything to do", x.anyTasksToDo()
+
+ #for item in x.tasksList:
+ # taskID = item[0]
+ # callFrom = item[1]
+ # callTo = item[2]
+ callFrom = "gsmrz1"
+ callTo = "sip"
+ #J = 1, 2
+ #for A in J:
+# print "call from to ", taskID , callFrom , callTo
+ print "Test Task : Calling from " +callFrom+ " to " +callTo
+ print ""
+
+
+ if callFrom == "sip" and sipServerStatus <> 0:
+
+ if callTo == "gsmrz1":
+
+ FuncTest("SIPCall.py", "localhost", "gsmincom_.py", "localhost","473")
+ print "Finish test"
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz2":
+
+ if gsmBox1Status <> 0:
+ FuncTest("SIPCall.py", "localhost", "Box1", "132.0.0.2","404")
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz3":
+
+ if gsmBox2Status <> 0:
+ FuncTest("SIPCall.py", "localhost", "Box2", "132.0.0.3","405")
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+
+ if callFrom =="gsmrz1":
+
+ if callTo =="sip" and sipServerStatus <> 0:
+ FuncTest("gsmcall_.py", "localhost", "SIPIncoming.py", "localhost","929")
+ sleep(10)
+
+
+ if callTo =="gsmrz2" and gsmBox1Status <> 0:
+ FuncTest("Box1", "132.0.0.2", "SIPReceiver.py", "localhost","929")
+
+ if callTo =="gsmrz3" and gsmBox2Status <> 0:
+ FuncTest("Box2", "132.0.0.3", "SIPReceiver.py", "localhost","929")
+
+
+
+
+# will exit if DB connection failed
+else:
+ sys.exit(5)
+
diff --git a/For Weekly Test/Old/15-07-2011/Controller-SecondType_withDB.py b/For Weekly Test/Old/15-07-2011/Controller-SecondType_withDB.py
new file mode 100644
index 0000000..1112c51
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/Controller-SecondType_withDB.py
@@ -0,0 +1,342 @@
+import sys
+import os
+import re
+import time
+import MySQLdb
+import subprocess
+
+
+import classClient #import class socket
+import classDb #import class db
+import classPing
+
+from time import sleep
+from datetime import datetime
+
+
+user = 'root'
+passw = 'randompasswordSQL' #default password we agree with this password before!
+host = 'localhost'
+dbname = 'gsmselftesting'
+
+stop = "False"
+status = ""
+dbSStatus = ""
+
+sipNum = "4661929"
+landlnNum = "076145875681"
+
+
+sipCall = "sipCall.py"
+sipRec = "sipReceiver.py"
+landlnCall = "LandlineCall.py"
+landlnRec = "LandlineReceiver.py"
+
+localSipRec = "localsipReceiver.py"
+rz1Call = "rz1Call.py"
+rz1Rec = "rz1Receiver.py"
+
+o2Call = "o2Call.py"
+o2Rec = "o2Receiver.py"
+vodafoneCall = "vodafoneCall.py"
+vodafoneRec = "vodafoneReceiver.py"
+tmobileCall = "tmobileCall.py"
+tmobilRec = "tmobileReceiver.py"
+
+# One function for all test case
+
+def FuncTest(orig, origAdd, dest, destAdd, destNo):
+
+ global repeatTest
+ global portOrig
+ global resultOrig
+ global resultDest
+ global x
+ global y
+ portOrig = None
+ resultOrig= None
+ resultDest = None
+
+
+ repeatTest = ""
+
+ try:
+
+ if dest =="gsmBox1" or dest =="gsmBox2":
+
+ if dest =="gsmBox1":
+ portOrig = 50095
+
+ if dest =="gsmBox2":
+ portOrig = 50096
+
+ print "GSM server handler", x.connect()
+ x.sendData('hello server please wakeup the handler and be caller')
+
+ else:
+ # open SIP caller handler
+
+ command="--command=python " +orig
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(5)
+
+ if orig=="sipCall.py":
+ portOrig = 50097
+
+ if orig=="gsmcall_.py":
+ portOrig = 50098
+
+ if orig == "landlineCall.py":
+ portOrig = 50099
+
+ if orig == "LocalSIPCall.py":
+ portOrig = 50100
+
+ #else: #mean external GSM
+ # print "have not yet define"
+ #portOrig = 50101
+
+ x = classClient.Connection(origAdd,portOrig)
+ print ""
+ print "Caller handler status:", x.connect()
+
+ x.sendData('hello Handler')
+
+ # wait respond from origin handler
+ while 1:
+ origHandler = x.receiveData()
+ if origHandler <> "":
+ break
+ #think about time out
+
+ if origHandler == "ready":
+ print "Caller handler ready"
+ print ""
+ try:
+ y = None
+ global portDest
+ portDest = None
+
+ if dest =="gsmBox1" or dest =="gsmBox2":
+
+ if dest =="gsmBox1":
+ portDest = 50102
+
+ if dest =="gsmBox2":
+ portDest = 50103
+
+ y = classClient.Connection(destAdd,portDest)
+ print "GSM handler", y.connect()
+ y.sendData('hello server please wakeup the handler and be receiver')
+
+ else:
+ command="--command=python " +dest
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(2)
+
+ if dest=="SIPIncoming.py":
+ portDest = 50104
+
+ if dest=="gsmincom_.py":
+ portDest = 50105
+
+ if dest == "landlineReceiver.py":
+ portDest = 50106
+
+ if dest == "LocalSIPReceiver.py":
+ portDest = 50107
+
+ #mean external GSM
+ #print "not define yet"
+ #portDest = 50108
+
+ y = classClient.Connection(destAdd,portDest)
+ print "Destination handler status:", y.connect()
+ y.sendData('hello Receiver, caller number')
+
+ #wait respond from destination handler
+ while 1:
+ destHandler = y.receiveData()
+ if destHandler <> "":
+ break
+ #should have timeout = think about timeout
+
+ if destHandler == "ready":
+
+ print "Destination handler ready"
+ print ""
+ y.closeConnection()
+ x.sendData("start")#send message to handler to start the call
+ sleep(1)
+ x.sendData(destNo)
+
+ #for refresh socket, so gsm handler can use socket to communicated with the phone
+ x.closeConnection()
+
+ print ""
+ #wait respond from both of handler
+ while 1:
+ sleep(5)
+ x.connect()
+ y.connect()
+ sleep(1)
+ resultOrig = x.receiveData()
+ resultDest = y.receiveData()
+ print "", resultDest
+ if resultOrig <> "" and resultDest <> "":
+ break
+
+ #if failed, try one more time
+ if resultOrig == "failed" or resultDest == "failed":
+ y.sendData('hello Destination Handler')
+ x.sendData("start")
+ sleep(2)
+ x.sendData(destNo)
+
+ #for refresh socket, so gsm handler can use socket to communicated with the phone
+ #x.closeConnection()
+ #x.connect()
+
+ while 1:
+ resultOrig = X.receiveData()
+ resultDest = y.receiveData()
+ print "Origin1: ", resultOrig
+ print "Destination1: ", resultDest
+
+ if resultOrig <> "" or resultDest <> "":
+ break
+
+ #if still failed, save to db and return repeat test, so we make automatic test vice versa
+ if resultOrig == "failed" or resultDest == "failed":
+ #db.execute ("update result table")
+ repeatTest="true"
+ print "Origin2: ", resultOrig
+ print "Destination1: ", resultDest
+
+ else: #save to database, tell handler to terminated
+ #db.execute ("update result table")
+ print "Test Result origin: ", resultOrig
+ print "Test Result Destination: ", resultDest
+ x.sendData('terminated') # signal caller to terminate
+ y.sendData('terminated') # signal receiver to terminate
+
+ else:
+ statusTest = "604 General Handler Error: Destination handler no respond"
+ #tell Caller handler to terminate because receiver doesnt work
+ x.sendData("terminated")
+
+ y.closeConnection()
+
+ except ValueError:
+ print "601 General Handler Error: Could not open Destination handler"
+ else:
+ statusTest = "605 General Handler Error: Origin handler no respond"
+
+ x.closeConnection()
+
+ except ValueError:
+ print "602 General Handler Error: Could not open Origin handler"
+
+
+
+# Main software
+
+
+
+# Check DB connection
+x = classDb.DBMySQLConnection(user, passw, host, dbname)
+print "connected to the DB ", x.connectDB()
+print ""
+dbStatus = x.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.4.60')
+ sipLocalServerStatus = sipLocalServer.ping(3)
+
+ #gsmBox1Status = FuncPing("132.230.4.8")
+ #gsmBox2Status = FuncPing("132.230.4.8")
+
+# Fetch The task information from DB
+ print "do i have anything to do", x.anyTasksToDo()
+
+ for item in x.tasksList:
+ taskID = item[0]
+ callFrom = item[1]
+ callTo = item[2]
+
+ print "call from to ", taskID , callFrom , callTo
+ print sipServerStatus
+
+ if callFrom == "sip" and sipServerStatus <> 0:
+
+ if callTo == "gsmrz1":
+
+ FuncTest(sipCall, "localhost", "gsmincom_.py", "localhost","4661455")
+ print "Finish test"
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz2":
+
+ if gsmBox1Status <> 0:
+ FuncTest(sipCall, "localhost", "Box1", "132.0.0.2","404")
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz3":
+
+ if gsmBox2Status <> 0:
+ FuncTest(sipCall, "localhost", "Box2", "132.0.0.3","405")
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+ if callTo == "landline" and sipGateSeverStatus <> 0:
+ FuncTest(sipCall, "localhost", landlnRec, "localhost",landlnNum)
+
+ if callTo == "localsip" and sipLocalSeverStatus <> 0:
+ FuncTest(sipCall, "localhost", localSipRec, "localhost","405")
+
+ if callTo == "externalgsm":
+ FuncTest(sipCall, "localhost", o2Rec, "localhost","405")
+ FuncTest(sipCall, "localhost", tmobileRec, "localhost","405")
+ FuncTest(sipCall, "localhost", vodafoneRec, "localhost","405")
+ FuncTest(sipCall, "localhost", "xx", "localhost","405")
+
+
+
+ if callFrom =="gsmrz1":
+
+ if callTo =="sip" and sipServerStatus <> 0:
+ FuncTest("gsmcall_.py", "localhost", sipRec, "localhost",sipNum)
+ sleep(10)
+
+
+ if callTo =="gsmrz2" and gsmBox1Status <> 0:
+ FuncTest("Box1", "132.0.0.2", sipRec, "localhost",sipNum)
+
+ if callTo =="gsmrz3" and gsmBox2Status <> 0:
+ FuncTest("Box2", "132.0.0.3", sipRec, "localhost",sipNum)
+
+
+
+
+# will exit if DB connection failed
+else:
+ sys.exit(5)
+
diff --git a/For Weekly Test/Old/15-07-2011/LandlineCall.py b/For Weekly Test/Old/15-07-2011/LandlineCall.py
new file mode 100644
index 0000000..a0b96e5
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/LandlineCall.py
@@ -0,0 +1,166 @@
+import sys
+import pjsua as pj
+
+import classServer
+
+from time import sleep
+from datetime import datetime
+import string
+
+
+stop =False
+
+
+LOG_LEVEL=2
+current_call = None
+status = None
+
+
+# Logging
+def log_cb(level, str, len):
+ print str, "SIP log"
+
+
+# Receive events from account
+class MyAccountCallback(pj.AccountCallback):
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+
+# Receive events from Call
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+
+ def on_state(self):
+ global current_call
+ global status
+
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ if self.call.info().state_text == "CONNECTING":
+ print "CONNECTING CALL"
+
+ print "CALL CONFIRMED and ESTABLISH", self.call.info().state_text
+ sleep(2)
+ current_call.hangup()
+ status = 200
+ server.sendData(status)
+ else:
+ sleep(0.5)
+
+
+ if self.call.info().last_reason <> "":
+
+ if self.call.info().last_reason == "Busy Here":
+
+ print "486 Busy Here"
+ print ""
+ status = 486
+ server.sendData(status)
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+ print 'Current call Disconnected'
+
+#Function to make call
+def make_call(uri):
+ try:
+ print "Making call to", uri
+ cb=MyCallCallback()
+ return acc.make_call(uri, cb)
+ except pj.Error, e:
+ print "408 Request Time-out (Couldn't find the user in time) " + str(e)
+ return None
+
+
+
+
+lib = pj.Lib()
+while stop <> True:
+
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+ server = classServer.ServerHandler(50097)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+ try:
+ acc_cfg = pj.AccountConfig("132.230.4.8","mpselftest1","1mpselftest")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+ print my_sip_uri
+
+ server.sendData('ready')
+ print "Status: ", server.connected
+
+ while 1:
+ try:
+ data = server.receiveData()
+
+ if data == "start":
+
+ while 1:
+
+ num = server.receiveData()
+ if num <> "":
+
+ number = "sip:"+num+"@132.230.4.8"
+ current_call = make_call(number)
+ break
+
+ if data == "487":
+ stop = True
+ break
+
+ except ValueError:
+ print "813 General socket layer error: Failed send message"
+ server.closeConnection()
+ del server
+
+ server.closeConnection()
+ del server
+
+ else:
+ Regis_status= "Bad"
+ print "488 Not Acceptable Here"
+
+ lib.destroy()
+ lib = None
+ acc = None
+
+
+ server.closeConnection()
+ del server
+ except ValueError:
+ print "401 Unauthorized " + str(e)
+
+print "Goodbye"
+sleep(3)
+acc.delete()
+lib.destroy()
+server.closeConnection()
+del server
+lib = None
+acc = None
+
diff --git a/For Weekly Test/Old/15-07-2011/LandlineReceiver.py b/For Weekly Test/Old/15-07-2011/LandlineReceiver.py
new file mode 100644
index 0000000..607f56d
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/LandlineReceiver.py
@@ -0,0 +1,160 @@
+import sys
+import pjsua as pj
+import string
+import classServer
+
+from time import sleep
+from datetime import datetime
+
+stop = False
+
+LOG_LEVEL=2
+current_call = None
+status = None
+global accept
+accept = None
+
+
+# Logging
+def log_cb(level, str, len):
+ print str, "SIP Handler Receiver Log"
+
+
+
+class MyAccountCallback(pj.AccountCallback):
+
+ global success
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+ def on_incoming_call(self, call):
+ global current_call
+ global number
+
+ if current_call:
+ call.answer(486, "Busy")
+ return
+
+ number = call.info().remote_uri
+
+ current_call = call
+
+ call_cb = MyCallCallback(current_call)
+ current_call.set_callback(call_cb)
+
+ current_call.answer(180)
+ print "accept call"
+
+ if current_call <> None:
+ accept = True
+
+ if accept == True:
+ sleep(0.5)
+ current_call.answer(200)
+ sleep(1.5)
+ current_call.hangup()
+ status = 200
+ server.sendData(success)
+
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+
+ def on_state(self):
+ global current_call
+ global success
+
+ if self.call.info().state == pj.CallState.CONNECTING:
+ print self.call.info().state_text
+ status = 200
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+ print '701 The called party has hung up'
+
+
+lib = pj.Lib()
+
+try:
+
+ server = classServer.ServerHandler(50104)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+
+ try:
+ acc_cfg = pj.AccountConfig("132.230.4.8", "mpselftest2", "2mpselftest")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+
+ server.sendData('ready')
+
+ while stop <> True:
+
+ data = server.receiveData()
+
+ if data == "487":
+ stop = True
+ break
+
+ if current_call == None:
+ accept = None
+ continue
+ else:
+ print "Incoming call from :", number
+
+
+
+
+ transport = None
+ acc.delete()
+ acc = None
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+
+ else:
+ print "Bad Register"
+
+ lib.destroy()
+ lib = None
+ acc = None
+ server.closeConnection()
+
+
+ except pj.Error, e:
+ print "401 Unauthorized " +str(e)
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ del server
diff --git a/For Weekly Test/Old/15-07-2011/classClient.py b/For Weekly Test/Old/15-07-2011/classClient.py
new file mode 100644
index 0000000..ce02d19
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/classClient.py
@@ -0,0 +1,66 @@
+import socket
+import sys
+import os
+import string
+
+class Connection:
+ def __init__(self, h, p):
+ self.host = h
+ self.port = p
+ self.s = None
+ self.connected = 0
+
+ def connect(self):
+ self.s = None
+
+ alive = self.ping()
+ if alive == 0:
+ return 'The machine is not alive'
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM):
+ af, socktype, proto, canonname, sa = res
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ continue
+ try:
+ self.s.connect(sa)
+ except socket.error, msg:
+ self.s.close()
+ self.connected = 0
+ self.s = None
+ continue
+ break
+ if self.s is None:
+ self.connected = 0
+ return 'Could not open socket'
+ else:
+ self.connected = 1
+ return 'Connected'
+
+ def sendData(self, data):
+ if self.connected == 1:
+ self.s.send(data)
+
+ def receiveData(self):
+ if self.connected == 1:
+ return self.s.recv(1024)
+ else:
+ return 'Not connected'
+
+ def closeConnection(self):
+ if self.connected == 1:
+ self.s.close()
+ self.connected = 0
+ return 'Closed'
+
+ def ping(self):
+ ping_cmd = os.popen('ping '+ self.host + ' -c 1 -W 1').read()
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ if pingAlive != -1:
+ return 1
+ else:
+ return 0
+
diff --git a/For Weekly Test/Old/15-07-2011/classClient.pyc b/For Weekly Test/Old/15-07-2011/classClient.pyc
new file mode 100644
index 0000000..b93c110
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/classClient.pyc
Binary files differ
diff --git a/For Weekly Test/Old/15-07-2011/classDb.py b/For Weekly Test/Old/15-07-2011/classDb.py
new file mode 100644
index 0000000..615b868
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/classDb.py
@@ -0,0 +1,212 @@
+import MySQLdb
+import string
+
+class DBMySQLConnection:
+ def __init__(self, username, password, host, dbname):
+ #initialize at the start all the user parameters
+ self.usern = username
+ self.passw = password
+ self.host = host
+ self.db = dbname
+ self.connectionCreated = 0
+ self.tasksList = list()
+ global debugMode
+ debugMode = 0
+
+ def connectDB(self):
+ try:
+ #try the connection
+ self.datBaseConn=MySQLdb.connect(self.host,self.usern, self.passw,self.db)
+ self.datBaseConn.paramstyle = 'format'
+ self.cur = self.datBaseConn.cursor() #make the cursor, used for sending queries
+ self.connectionCreated = 1 #use it as an indicator that the connection was created
+ return 1
+
+ except MySQLdb.Error, e:
+ #if we have an error then try to catch it
+ error=str(e)
+ if error[1:5] == '1045':
+ #wrong username or password
+ return 0
+ elif error[1:5] == '2002':
+ #can't connect to mysql, mysql shutdown or wrong host
+ return 2
+ else:
+ if debugMode == 1:
+ print error
+ return 3
+
+ def closeDBConn(self):
+ #close the connection to the database here
+ if self.connectionCreated == 1:
+ try:
+ #close the cursor and then the connection to the DB
+ self.cur.close()
+ self.datBaseConn.close()
+ return 1
+ except MySQLdb.Error, e:
+ #in case of an error
+ if debugMode == 1:
+ error = str(e)
+ print error
+ return 3
+ else:
+ #I never really had a connection
+ return 0
+
+ def anyTasksToDo(self):
+ #see are there any jobs to be executed and make a list out of it
+ if self.connectionCreated == 1:
+ try:
+ self.cur.execute("SELECT * FROM TempTaskTable")
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+ for record in output:
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+ self.tasksList.append(columns)
+ return 1
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def cleanTasksList(self):
+ if self.connectionCreated == 1:
+ del self.tasksList[:]
+ return 1
+ else:
+ return 0
+
+ def removeTaskFromList(self, taskID):
+ #remove only one task from the task list
+ if self.connectionCreated == 1:
+ for index in range(len(self.tasksList)):
+ item = self.tasksList[index]
+ if item[0] == str(taskID):
+ #self.tasksList.remove(index)
+ #print 'found it'
+ del self.tasksList[index]
+ return 1 #deleted taskID
+
+ return 2 #didn't find that taskID
+ else:
+ return 0
+
+ def deviceAddress(self,deviceName):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("SELECT `deviceIP` FROM DeviceAddress where `deviceName`=%s", deviceName)
+ #self.cur.execute()
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+ deviceAddr = ''
+ for record in output:
+ columns = list()
+ for entry in record:
+ deviceAddr = str(entry)
+ return deviceAddr
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3 #some error happened
+ else:
+ return 0 #I am not connected
+
+ def updateTaskResult(self, taskID, status):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE TaskTable SET status=%i WHERE taskID=%i"%(int(status), int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #update successful
+ else:
+ return 4 #taskID doesn't exist
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def updatePingResult(self, taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE PingResultTable SET sipServer=%i, sipGate=%i, sipLoc=%i, gsmBox1=%i, gsmBox2=%i WHERE taskNo=%i"%(int(sipServer), int(sipGate), int(sipLoc), int(gsmBox1), int(gsmBox2), int(taskNo)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #ping table updated
+ else:
+ return 4 #the taskNo didn't exist
+
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def deleteTempTask(self, taskID):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("DELETE FROM TempTaskTable WHERE taskID=%i"%(int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+
+ if successful == 1:
+ return 1 #deleted it
+ else:
+ return 4 #that taskID didn't exist or something else
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+
+ else:
+ return 0
+
+ def addResult(self, taskID, result):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("INSERT INTO ResultTable(taskID, result) VALUES ('%i', '%i')"%(int(taskID), int(result)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 1:
+ return 1 #successfully added the result
+ else:
+ return 4 #hmmm
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1062':
+ return 2 #duplicate entry for the key
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
diff --git a/For Weekly Test/Old/15-07-2011/classDb.pyc b/For Weekly Test/Old/15-07-2011/classDb.pyc
new file mode 100644
index 0000000..92d31c6
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/classDb.pyc
Binary files differ
diff --git a/For Weekly Test/Old/15-07-2011/classPing.py b/For Weekly Test/Old/15-07-2011/classPing.py
new file mode 100644
index 0000000..e13b32b
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/classPing.py
@@ -0,0 +1,28 @@
+import subprocess
+import string
+
+class Ping:
+
+ def __init__(self, pingAddress):
+ self.pingAddress = pingAddress
+
+ def ping(self,numberTries):
+ tried = 1
+ while numberTries >= tried:
+ tried += 1
+ #the parameter c 1 means only one ping to be sent, parameter W 3 means how many seconds the time out should be, 3 seconds
+ ping_cmd = subprocess.Popen(['ping', self.pingAddress, '-c', '1', '-W', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ unknownHost = int(string.find(ping_cmd, 'unknown host'))
+
+
+ if pingAlive != -1:
+ break
+
+ if unknownHost != -1:
+ return 2 #unknown host
+ if pingAlive != -1:
+ return 1 #ping works fine
+ else:
+ return 0 #no ping response
diff --git a/For Weekly Test/Old/15-07-2011/classPing.pyc b/For Weekly Test/Old/15-07-2011/classPing.pyc
new file mode 100644
index 0000000..cab2db5
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/classPing.pyc
Binary files differ
diff --git a/For Weekly Test/Old/15-07-2011/classServer.py b/For Weekly Test/Old/15-07-2011/classServer.py
new file mode 100644
index 0000000..97a398d
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/classServer.py
@@ -0,0 +1,94 @@
+# Echo server program
+import socket
+import sys
+import os
+import string
+from time import sleep
+
+class ServerHandler:
+
+ def __init__(self,p):
+ self.port = p
+ self.host = None #symbolic name meaning all available interfaces
+ self.s = None
+ self.connected = 0
+ self.address = "127.0.0.1" #address of the main controller
+ self.onceConnected = 0
+ self.error = 'No error'
+
+ def openSocket(self):
+ self.error = 'No error'
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC,
+ socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
+ af, socktype, proto, canonname, sa = res
+
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+
+ try:
+ self.s.bind(sa)
+ self.s.listen(1)
+ except socket.error, msg:
+ self.s.close()
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+ break
+
+ if self.s is None:
+ self.connected = 0
+ return 0
+ else: #accept the connection
+ self.connection, self.address = self.s.accept()
+ self.connected = 1
+ self.onceConnected = 1
+ return 1
+
+ def connectedTo(self):
+ return self.address
+
+ def receiveData(self):
+ if self.connected == 1:
+ while 1:
+ data = self.connection.recv(64)
+ if not data:
+ return 'NO DATA'
+ else:
+ return data
+ else:
+ return 0
+
+ def sendData(self, data):
+ if self.connected == 1:
+ self.connection.send(data)
+ return 1
+ else:
+ return 0
+
+ def closeConnection(self):
+ if self.onceConnected == 1:
+ self.connection.close()
+ self.s.close()
+ self.s = None
+ self.connected == 0
+ return 1
+ else:
+ return 0
+
+ def killPort(self):
+ killResult = os.popen('lsof -i tcp:' + str(self.port) + ' | grep "python " | awk -F" " ' + "'{print $2}'").read()
+ killResult = killResult.replace('\n','')
+ print killResult
+ if killResult!='':
+ print killResult
+ killPort = os.popen("kill -9 " + killResult).read()
+ return 1
+ return 0
+
diff --git a/For Weekly Test/Old/15-07-2011/classServer.pyc b/For Weekly Test/Old/15-07-2011/classServer.pyc
new file mode 100644
index 0000000..52f5085
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/classServer.pyc
Binary files differ
diff --git a/For Weekly Test/Old/15-07-2011/gsmcall2_.py b/For Weekly Test/Old/15-07-2011/gsmcall2_.py
new file mode 100644
index 0000000..bf8e662
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/gsmcall2_.py
@@ -0,0 +1,102 @@
+import sys
+import pjsua as pj
+import socket
+import time
+
+import subprocess
+import os
+from serial import *
+
+import classServer
+
+from time import sleep
+from datetime import datetime
+import string
+
+
+stop ="false"
+success = "failed"
+
+
+try:
+ global ser
+ portAddress = '/dev/ttyUSB0'
+ portName = portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+
+ ser.open()
+
+ server = classServer.ServerHandler(50098)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ server.sendData('ready')#send message to controller
+ print "Status Server:", server.connected
+ print ""
+
+ while stop <> "true":
+ try:
+ data = server.receiveData() # waiting mode, until receiver start message or terminate message
+ ser.write('AT+CSQ\r')
+ signalQuality = ser.read(35)
+ print "Signal Bar: ", signalQuality
+ #
+
+
+ if data == "start": # if receiver start message, handler start to call destination
+ while 1:
+
+ num = server.receiveData() # waiting destination number
+
+ #num = 929
+
+ if num <> "":
+
+ ser.write('ATD' + num + ';\r')
+ sleep(5)
+ success = "success"
+ server.sendData(success)
+ ser.write('AT+CHUP\r')
+
+ break
+
+ if data == "terminated": # will terminate the handler if controller send terminate message
+ stop = "true"
+ break
+
+ except ValueError:
+ print "error on calling mode"
+ server.closeConnection()
+ del server
+
+
+
+ server.sendData(success)
+ server.closeConnection()
+ ser.close()
+ del server
+
+except ValueError:
+ print "Exception: "
+
+print "Goodbye"
+sleep(3)
diff --git a/For Weekly Test/Old/15-07-2011/gsmcall_.py b/For Weekly Test/Old/15-07-2011/gsmcall_.py
new file mode 100644
index 0000000..55c599e
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/gsmcall_.py
@@ -0,0 +1,105 @@
+import sys
+import socket
+import time
+
+import subprocess
+import os
+from serial import *
+
+import classServer
+
+from time import sleep
+import string
+
+
+stop ="false"
+success = "failed"
+
+global server
+
+global ser
+portAddress = '/dev/ttyACM0'
+portName = portAddress[-4:]
+portExist = os.popen('dmesg | grep ' + portName).read()
+
+if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+
+
+while stop <> "true":#???
+
+
+ try:
+
+ server = classServer.ServerHandler(50098)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ server.sendData('ready')#send message to controller
+ print "Controller status: ", server.connected
+
+
+ while stop <> "true":
+ try:
+ data = server.receiveData() # waiting mode, until receiver start message or terminate message
+
+ if data == "start": # if receiver start message, handler start to call destination
+
+ while 1:
+
+ num = server.receiveData()
+
+ #num = "929"
+ if num <> "NO DATA":
+ server.closeConnection()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+ ser.close()
+ ser.open()
+
+ ser.write('ATD4661' + num + ';\r')
+ sleep(3)
+ ser.write('AT+CHUP\r')
+
+ ser.close()
+ tried = server.openSocket()
+ sleep(2)
+ success = "success"
+ server.sendData(success)
+
+ if data == "terminated": # will terminate the handler if controller send terminate message
+ stop = "true"
+ break
+
+ except ValueError:
+ print "error when sending message"
+ server.closeConnection()
+ del server
+
+
+ server.closeConnection()
+ del server
+ print "Goodbye"
+ sleep(3)
+ sys.exit(1)
+
+ except ValueError:
+ print "Exception: " + str(e)
+
+print "Goodbye"
+sleep(3)
diff --git a/For Weekly Test/Old/15-07-2011/gsmincom_.py b/For Weekly Test/Old/15-07-2011/gsmincom_.py
new file mode 100644
index 0000000..413db25
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/gsmincom_.py
@@ -0,0 +1,134 @@
+
+import atexit
+import signal
+
+import sys
+import socket
+import time
+import os
+import string
+import classServer
+from time import sleep
+from serial import *
+
+
+success = None
+stop = False
+
+try:
+
+ global ser
+ global server
+ portAddress = '/dev/ttyUSB0'
+ portName = portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+
+
+ server = classServer.ServerHandler(50105)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ print "here:", server.connected
+ if server.connected == 1:
+
+ server.sendData('ready')
+ server.closeConnection()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+ ser.close()
+ ser.open()
+
+ signalQuality = ser.write('AT+CSQ\r')
+ print "signal Quality ", signalQuality
+ print ""
+
+
+
+ while stop <> True:
+
+ global pickUp
+ pickUp = None
+ buffer = ""
+
+
+ buffer = buffer + ser.read(ser.inWaiting()) #read the serial port and add it to the buffer variable
+ if '\n' in buffer:
+ #if a new line character is found in the buffer then the cellphone has sent something
+ lines = buffer.split('\n') #parse the buffer variable with the new line character
+ last_received = lines.pop(0) #put into last_received variable the first content from lines (FIFO)
+ print "apa iyi", buffer
+ #buffer = "".join(lines) #add a new line to the buffer variable
+
+ last_received=last_received.split('\n') #parse the last received value with new lines
+ line = last_received[0].replace(chr(13), '')
+
+ print "buffer:", buffer
+ print "line:", line
+ linesa = ser.read(ser.inWaiting())
+ print "new line:", linesa
+ sleep(1)
+
+ if line =="RING" or linesa =="RING":
+
+
+ if line =="RING" or lines =="RING":
+
+ print "Somebody calling"
+ print ""
+ sleep(1)
+ ser.write('ATA\r')
+
+
+ print "I will hangup the call"
+ print ""
+ sleep(1)
+
+ ser.write('AT+CHUP\r')
+ pickUp = 0
+ ser.close()
+
+ print "here I am"
+ tried = server.openSocket()
+
+ sleep(1)
+ server.sendData('success')
+ stop = True
+ sleep (5)
+ break
+
+
+
+ server.closeConnection()
+ del server
+ else:
+
+ print "not connected"
+
+ del server
+
+ ser.close()
+except ValueError:
+ print "Exception: "
+ server.closeConnection()
+ del server
+
+print "GOODBYE"
+sleep(5)
diff --git a/For Weekly Test/Old/15-07-2011/localsipReceiver.py b/For Weekly Test/Old/15-07-2011/localsipReceiver.py
new file mode 100644
index 0000000..96f058f
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/localsipReceiver.py
@@ -0,0 +1,160 @@
+import sys
+import pjsua as pj
+import string
+import classServer
+
+from time import sleep
+from datetime import datetime
+
+stop = False
+
+LOG_LEVEL=2
+current_call = None
+status = None
+global accept
+accept = None
+
+
+# Logging
+def log_cb(level, str, len):
+ print str, "SIP Handler Receiver Log"
+
+
+
+class MyAccountCallback(pj.AccountCallback):
+
+ global success
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+ def on_incoming_call(self, call):
+ global current_call
+ global number
+
+ if current_call:
+ call.answer(486, "Busy")
+ return
+
+ number = call.info().remote_uri
+
+ current_call = call
+
+ call_cb = MyCallCallback(current_call)
+ current_call.set_callback(call_cb)
+
+ current_call.answer(180)
+ print "accept call"
+
+ if current_call <> None:
+ accept = True
+
+ if accept == True:
+ sleep(0.5)
+ current_call.answer(200)
+ sleep(1.5)
+ current_call.hangup()
+ status = 200
+ server.sendData(success)
+
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+
+ def on_state(self):
+ global current_call
+ global success
+
+ if self.call.info().state == pj.CallState.CONNECTING:
+ print self.call.info().state_text
+ status = 200
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+ print '701 The called party has hung up'
+
+
+lib = pj.Lib()
+
+try:
+
+ server = classServer.ServerHandler(50104)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+
+ try:
+ acc_cfg = pj.AccountConfig("132.230.252.228", "4976120397897", "hB8M3WyFt61C")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+
+ server.sendData('ready')
+
+ while stop <> True:
+
+ data = server.receiveData()
+
+ if data == "487":
+ stop = True
+ break
+
+ if current_call == None:
+ accept = None
+ continue
+ else:
+ print "Incoming call from :", number
+
+
+
+
+ transport = None
+ acc.delete()
+ acc = None
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+
+ else:
+ print "Bad Register"
+
+ lib.destroy()
+ lib = None
+ acc = None
+ server.closeConnection()
+
+
+ except pj.Error, e:
+ print "401 Unauthorized " +str(e)
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ del server
diff --git a/For Weekly Test/Old/15-07-2011/sipCall.py b/For Weekly Test/Old/15-07-2011/sipCall.py
new file mode 100644
index 0000000..0dbc133
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/sipCall.py
@@ -0,0 +1,180 @@
+import sys
+import pjsua as pj
+import socket
+import time
+import MySQLdb
+import subprocess
+
+import classServer
+
+from time import sleep
+from datetime import datetime
+import string
+
+
+stop ="false"
+server = "132.230.4.8"
+username = "mpselftest1"
+password = "1mpselftest"
+
+LOG_LEVEL=2
+current_call = None
+success = ""
+
+
+# Logging callback
+def log_cb(level, str, len):
+ print str, "SIP log"
+
+
+# Callback to receive events from account
+class MyAccountCallback(pj.AccountCallback):
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+ # Notification on incoming call##
+
+
+
+# Callback to receive events from Call
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+ # Notification when call state has changed
+ def on_state(self):
+ global current_call
+ global success
+
+ if self.call.info().state_text <> "DISCONNCTD":
+ if self.call.info().state_text == "CONNECTING":
+ print "CONNECTING CALL"
+ #print "isine opo:", self.call.info().state_text
+ print "CALL CONFIRMED and ESTABLISH", self.call.info().state_text
+ sleep(1)
+ current_call.hangup()
+ print "I am here now"
+ success = "true"
+ server.sendData(success)
+ else:
+ sleep(1)
+ #print ""
+
+ if self.call.info().last_reason <> "":
+
+ if self.call.info().last_reason == "Busy Here":
+
+ print "Destination Number is Busy or offline"
+ print ""
+ success = "false"
+ server.sendData(success)
+
+
+ #print self.call.info().state_text
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+ print 'Current call Disconnected'
+
+
+def make_call(uri):
+ try:
+ print "Making call to", uri
+ cb=MyCallCallback()
+ return acc.make_call(uri, cb)
+ except pj.Error, e:
+ print "Exception: " + str(e)
+ return None
+
+
+
+
+lib = pj.Lib()
+while stop <> "true":
+
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+ lib.start()
+ lib.set_null_snd_dev()
+
+ # open socket connection and connect to the controller
+ server = classServer.ServerHandler(50097)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+ try:
+ acc_cfg = pj.AccountConfig("132.230.4.8","mpselftest1","1mpselftest")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+ print my_sip_uri
+ server.sendData('ready')#send message to controller
+ print "here:", server.connected
+ while 1:
+ try:
+ data = server.receiveData() # waiting mode, until receiver start message or terminate message
+
+ if data == "start": # if receiver start message, handler start to call destination
+
+ while 1:
+
+ num = server.receiveData() # waiting destination number
+ print num
+ server.closeConnection()
+ tried = server.openSocket()
+ if num <> "":
+
+ number = "sip:"+num+"@132.230.4.8"
+ current_call = make_call(number)
+ break
+
+ if data == "terminated": # will terminate the handler if controller send terminate message
+ stop = "true"
+ break
+
+ except ValueError:
+ print "error when sending message"
+ server.closeConnection()
+ del server
+
+ server.closeConnection()
+ del server
+
+ else:
+ Regis_status= "Bad"
+ print "error when register"
+
+ lib.destroy()
+ lib = None
+ acc = None
+
+
+ server.closeConnection()
+ del server
+ except ValueError:
+ print "Exception: " + str(e)
+
+print "Goodbye"
+sleep(3)
+acc.delete()
+lib.destroy()
+server.closeConnection()
+del server
+lib = None
+acc = None
+
diff --git a/For Weekly Test/Old/15-07-2011/sipReceiver.py b/For Weekly Test/Old/15-07-2011/sipReceiver.py
new file mode 100644
index 0000000..6404f10
--- /dev/null
+++ b/For Weekly Test/Old/15-07-2011/sipReceiver.py
@@ -0,0 +1,177 @@
+import sys
+import pjsua as pj
+import socket
+import time
+import os
+import string
+import classServer
+
+from time import sleep
+from datetime import datetime
+
+stop ="false"
+server = "132.230.4.8"
+username = "mpselftest2"
+password = "2mpselftest"
+
+LOG_LEVEL=2
+current_call = None
+success = ""
+global accept
+accept = None
+
+
+# Logging callback
+def log_cb(level, str, len):
+ print str, "I am here"
+
+
+# Callback to receive events from account
+class MyAccountCallback(pj.AccountCallback):
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+ # Notification on incoming call
+ def on_incoming_call(self, call):
+ global current_call
+ global number
+ if current_call:
+ call.answer(486, "Busy")
+ return
+
+ number = call.info().remote_uri
+
+ current_call = call
+
+ call_cb = MyCallCallback(current_call)
+ current_call.set_callback(call_cb)
+
+ current_call.answer(180)
+ print "accept call"
+ if current_call <> None:
+ accept = True
+ if accept == True:
+ sleep(2)
+ current_call.answer(200)
+ sleep(3)
+ current_call.hangup()
+ accept = "true"
+ server.sendData('success')
+
+ #server.sendData(success)
+
+
+
+
+
+# Callback to receive events from Call
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+ # Notification when call state has changed
+ def on_state(self):
+ global current_call
+
+ if self.call.info().state_text == "CONNECTING":
+ print self.call.info().state_text
+ success = "success"
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+ print 'Current call is', current_call
+
+ # Notification when call's media state has changed.
+ def on_media_state(self):
+ if self.call.info().media_state == pj.MediaState.ACTIVE:
+ # Connect the call to sound device
+ call_slot = self.call.info().conf_slot
+ pj.Lib.instance().conf_connect(call_slot, 0)
+ pj.Lib.instance().conf_connect(0, call_slot)
+ #server.sendData('establish connection')
+
+ print "Media is now active"
+
+
+ else:
+ print "Media is inactive"
+
+
+
+lib = pj.Lib()
+
+try:
+ #open socket connection to the controller
+ server = classServer.ServerHandler(50104)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+
+
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+
+ # Start the library
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+ # Create local account
+ acc_cfg = pj.AccountConfig("132.230.4.8", "mpselftest2", "2mpselftest")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+
+ server.sendData('ready')#send message to controller that the handler ready
+
+ while stop <> "true":
+
+ data = server.receiveData()#waiting message from controller
+ if data == "terminated":
+ break
+
+ if current_call == None:
+ accept = None
+ continue
+ else:
+ print "Incoming call from :", number
+
+ sleep(4)
+
+
+ # Shutdown the library
+ transport = None
+ acc.delete()
+ acc = None
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ del server
+ else:
+ Regis_status= "Bad"
+ print "error when register"
+
+ lib.destroy()
+ lib = None
+ acc = None
+ server.closeConnection()
+ del server
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ del server
diff --git a/For Weekly Test/Old/20-07-2011/Controller.py b/For Weekly Test/Old/20-07-2011/Controller.py
new file mode 100644
index 0000000..c1d63a4
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/Controller.py
@@ -0,0 +1,183 @@
+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"
+
+
+sipCall = "sipCall.py"
+sipRec = "sipReceiver.py"
+landlnCall = "landlineCall.py"
+landlnRec = "landlineReceiver.py"
+localSipRec = "localsipReceiver.py"
+
+
+# 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(sipCall, "localhost", "gsmincom_.py", "localhost","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(sipCall, "localhost", "Box1", "132.0.0.2","404")
+ 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(sipCall, "localhost", "Box2", "132.0.0.3","405")
+ 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(sipCall, "localhost", landlnRec, "localhost",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(sipCall, "localhost", localSipRec, "localhost",unisipNum)
+ x.FuncTest()
+
+ db.addResult(taskID, x.testResult)
+ sleep(5)
+
+ if callTo == "externalgsm":
+ x.FuncTest(sipCall, "localhost", o2Rec, "localhost","405")
+ db.addResult(taskID, testResult)
+
+ x.FuncTest(sipCall, "localhost", tmobileRec, "localhost","405")
+ db.addResult(taskID, testResult)
+
+ x.FuncTest(sipCall, "localhost", vodafoneRec, "localhost","405")
+ db.addResult(taskID, testResult)
+
+ x.FuncTest(sipCall, "localhost", "xx", "localhost","405")
+ db.addResult(taskID, testResult)
+
+
+
+ if callFrom =="gsmrz1":
+
+ if callTo =="sip":
+ if sipServerStatus == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest("gsmcall_.py", "localhost", sipRec, "localhost",sipNum)
+ db.addResult(taskID, testResult)
+ sleep(10)
+
+
+ if callTo =="gsmrz2":
+ if gsmBox1Status == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest("Box1", "132.0.0.2", sipRec, "localhost",sipNum)
+ db.addResult(taskID, testResult)
+
+ if callTo =="gsmrz3":
+ if gsmBox2Status == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest("Box2", "132.0.0.3", sipRec, "localhost",sipNum)
+ db.addResult(taskID, testResult)
+
+
+
+
+# will exit if DB connection failed
+else:
+ sys.exit(5)
+
diff --git a/For Weekly Test/Old/20-07-2011/LogFileClass.py b/For Weekly Test/Old/20-07-2011/LogFileClass.py
new file mode 100644
index 0000000..cb152f4
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/LogFileClass.py
@@ -0,0 +1,21 @@
+import string
+import datetime
+
+class Logging:
+
+ def __init__(self, logFileName):
+ self.writeToFile = open(logFileName, 'a')
+ self.justStarted = 1
+
+ def logEvent(self, event):
+ now = str(datetime.datetime.now())
+ if self.justStarted == 1:
+ self.writeToFile.write('\n\n------------------STARTED THE LOGGING '+ now + ' ------------------\n')
+ self.justStarted = 0
+ else:
+ self.writeToFile.write('On: '+ now + '\t' + 'Event: ' +str(event) + '\n')
+
+ def closeLogging(self):
+ now = str(datetime.datetime.now())
+ self.writeToFile.write('------------------FINISHED THE LOGGING '+ now + ' ------------------')
+ self.writeToFile.close()
diff --git a/For Weekly Test/Old/20-07-2011/LogFileClass.pyc b/For Weekly Test/Old/20-07-2011/LogFileClass.pyc
new file mode 100644
index 0000000..511a60e
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/LogFileClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/20-07-2011/Testing.py b/For Weekly Test/Old/20-07-2011/Testing.py
new file mode 100644
index 0000000..34316ee
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/Testing.py
@@ -0,0 +1,44 @@
+import sys
+import os
+import time
+import MySQLdb
+import subprocess
+import signal
+
+import classClient
+import classDb
+import classPing
+
+from time import sleep
+
+command="--command=python sipCall.py"
+subprocess.Popen(args=["gnome-terminal", command])
+sleep(5)
+x = classClient.Connection("localhost", "50097")
+x.connect()
+origHandler = x.receiveData(0)
+print origHandler
+
+#command="--command=python localsipReceiver.py"
+#subprocess.Popen(args=["gnome-terminal", command])
+sleep(5)
+y = classClient.Connection("localhost", "50107")
+y.connect()
+
+while 1:
+ destHandler = y.receiveData(0)
+ if destHandler <> "":
+ break
+
+print destHandler
+
+if destHandler == "ready":
+ y.closeConnection()
+ y.connect()
+
+ #x.sendData("start|076120397897")
+while 1:
+ destHandlers = y.receiveData(0)
+ #origHandlers = x.receiveData(0)
+
+ print destHandlers#, origHandlers
diff --git a/For Weekly Test/Old/20-07-2011/UniSIPRecHandler.log b/For Weekly Test/Old/20-07-2011/UniSIPRecHandler.log
new file mode 100644
index 0000000..a203845
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/UniSIPRecHandler.log
@@ -0,0 +1,15 @@
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:40:01.724672 ------------------
+On: 2011-07-19 13:40:01.724716 Event: Connect to Controller via port 50107
+On: 2011-07-19 13:40:03.587386 Event: Register Account to University SIP server
+On: 2011-07-19 13:40:03.587623 Event: 100
+On: 2011-07-19 13:40:08.589638 Event: Handler Ready
+On: 2011-07-19 13:40:08.621158 Event: {Call "mpselftest1" <sip:4661928@132.230.252.228>}
+On: 2011-07-19 13:40:09.122499 Event: Answer call
+On: 2011-07-19 13:40:09.623197 Event: Hangup call
+On: 2011-07-19 13:40:09.623657 Event: 200
+On: 2011-07-19 13:40:10.144886 Event: Terminate
+On: 2011-07-19 13:40:10.145237 Event: Un-Rigester SIP Account
+On: 2011-07-19 13:40:11.577828 Event: Close Connection to the Controller
+On: 2011-07-19 13:40:11.577983 Event: Close Connection to the Controller
diff --git a/For Weekly Test/Old/20-07-2011/classClient.py b/For Weekly Test/Old/20-07-2011/classClient.py
new file mode 100644
index 0000000..46c3b00
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classClient.py
@@ -0,0 +1,123 @@
+import socket
+import sys
+import os
+import string
+import signal
+
+class TimeoutException(Exception):
+ pass
+
+class Connection:
+ def __init__(self, h, p):
+ self.host = h
+ self.port = p
+ self.s = None
+ self.connected = 0
+
+ self.debugMode = 0
+
+ def connect(self):
+ self.s = None
+
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM):
+ af, socktype, proto, canonname, sa = res
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ continue
+ try:
+ self.s.connect(sa)
+ except socket.error, msg:
+ self.s.close()
+ self.connected = 0
+ self.s = None
+ continue
+ break
+ if self.s is None:
+ self.connected = 0
+ return 0 #couldn't connect to the server
+ else:
+ self.connected = 1
+ return 1 #successfully connected to the server
+
+ def sendData(self, data):
+ if self.connected == 1:
+ try:
+ self.s.send(data)
+ return 1
+ except Exception, e:
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ return 2
+
+ else:
+ return 0
+
+ def receiveData(self, timeout):
+ if self.connected == 1:
+
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(timeout) #start the timeout alarm, for timeout seconds
+ try:
+ data = self.s.recv(1024)
+
+ #stop the timeout function
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ return data
+
+
+ except TimeoutException:
+ #timeout happened
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'TIMEOUT'
+
+ except Exception, e:
+
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ if error[0:11] == '[Errno 104]':
+ return 3 #the other side reset the connection,[Errno 104] Connection reset by peer
+
+ return 2
+ else:
+ return 0
+
+ def closeConnection(self):
+ if self.connected == 1:
+ try:
+ self.connected = 0
+ SHUT_RDWR = 2
+ self.s.shutdown(SHUT_RDWR)
+ self.s.close()
+ return 1
+ except Exception, e:
+ self.connected = 0
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ if error[0:11] == '[Errno 107]':
+ return 3 #the other side closed the connection before us, [Errno 107] Transport endpoint is not connected
+ return 2
+ else:
+ return 0
diff --git a/For Weekly Test/Old/20-07-2011/classClient.pyc b/For Weekly Test/Old/20-07-2011/classClient.pyc
new file mode 100644
index 0000000..fbfa63d
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classClient.pyc
Binary files differ
diff --git a/For Weekly Test/Old/20-07-2011/classController.py b/For Weekly Test/Old/20-07-2011/classController.py
new file mode 100644
index 0000000..b7e3bff
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classController.py
@@ -0,0 +1,239 @@
+import sys
+import os
+import time
+import MySQLdb
+import subprocess
+import signal
+
+import classClient
+import classDb
+import classPing
+
+from time import sleep
+
+class TimeoutException(Exception):
+ pass
+
+class test:
+
+ def __init__(self, orig, origAdd, dest, destAdd, destNo):
+ self.orig = orig
+ self.origAdd = origAdd
+ self.dest = dest
+ self.destAdd = destAdd
+ self.destNo = destNo
+ self.repeatTest = None
+ self.portOrig = None
+ self.resultOrig = None
+ self.resultDest = None
+ self.testResult = None
+ self.x = None
+ self.y = None
+
+ def FuncTest(self):
+
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+ print ""
+ print "====================== Preparing Test ======================"
+
+ try:
+
+ if self.dest =="gsmBox1" or self.dest =="gsmBox2":
+
+ if self.dest =="gsmBox1":
+ portOrig = 50095
+
+ if self.dest =="gsmBox2":
+ portOrig = 50096
+
+ print ""
+ print "Connecting to Caller handler"
+ x.connect()
+ x.sendData('be caller')
+
+ else:
+ # open SIP caller handler
+
+ command="--command=python " +self.orig
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(5)
+
+ if self.orig=="sipCall.py":
+ self.portOrig = 50097
+
+ if self.orig == "landlineCall.py":
+ self.portOrig = 50099
+
+ if self.orig == "LocalSIPCall.py":
+ self.portOrig = 50100
+
+
+ x = classClient.Connection(self.origAdd,self.portOrig)
+ print ""
+ print "Connecting to Caller handler"
+ x.connect()
+
+ # wait respond from origin handler
+ signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(60)
+
+ while 1:
+ try:
+ origHandler = x.receiveData(0)
+ if origHandler <> "":
+ break
+
+ except TimeoutException:
+ origHandler = "failed"
+ break
+
+
+ if origHandler == "ready":
+ print "Caller handler : Ready"
+ print ""
+ try:
+ if self.dest =="gsmBox1" or self.dest =="gsmBox2":
+
+ if self.dest =="gsmBox1":
+ self.portDest = 50102
+
+ if self.dest =="gsmBox2":
+ self.portDest = 50103
+
+ y = classClient.Connection(self.destAdd, self.portDest)
+ print "Connecting to Receiver handler"
+ y.connect()
+ y.sendData('receiver')
+
+ else:
+ command="--command=python " +self.dest
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(2)
+
+ if self.dest=="SIPReceiver.py":
+ self.portDest = 50104
+
+ if self.dest == "landlineReceiver.py":
+ self.portDest = 50106
+
+ if self.dest == "localsipReceiver.py":
+ self.portDest = 50107
+
+ y = classClient.Connection(self.destAdd, self.portDest)
+ print "Connecting to Receiver handler"
+ y.connect()
+
+
+ signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(60)
+
+ while 1:
+ try:
+ destHandler = y.receiveData(0)
+ if destHandler <> "":
+ break
+
+ except TimeoutException:
+ destHandler = "failed"
+ break
+
+ if destHandler == "ready":
+
+ print "Receiver handler : Ready"
+
+ x.sendData("start|"+self.destNo)#send message to handler to start the call
+
+
+ signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(120)
+
+ print ""
+ print "------------ Test Result ------------"
+ print ""
+
+ while 1:
+ try:
+ sleep(0.5)
+ self.resultOrig = x.receiveData(0)
+ self.resultDest = y.receiveData(0)
+
+ if self.resultOrig <> "" and self.resultDest <> "":
+ break
+
+ except TimeoutException:
+ self.resultOrig = 486
+ self.resultDest = 486
+ break
+
+ #if failed, tell everybody to try one more time
+ if self.resultOrig == 486 or self.resultDest == 486:
+
+ x.sendData("start|"+self.destNo)
+
+ signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(120)
+
+ while 1:
+ try:
+ sleep(0.5)
+ self.resultOrig = x.receiveData(0)
+ self.resultDest = y.receiveData(0)
+
+ if self.resultOrig <> "" and self.resultDest <> "":
+ print "here"
+ break
+
+ except TimeoutException:
+ self.resultOrig = 486
+ self.resultDest = 486
+ break
+
+ #if still failed, we make automatic test vice versa
+
+ if self.resultOrig == 486 or self.resultDest == 486:
+ self.testResult = 486
+ self.repeatTest = True
+
+ print "Second test result origin: ", self.resultOrig
+ print "Second test result Destination: ", self.resultDest
+ else:
+ self.testResult = 200
+
+ print "Second test result origin: ", self.resultOrig
+ print "Second test result Destination: ", self.resultDest
+ x.sendData('487')
+ y.sendData('487')
+
+ else:
+
+ self.testResult = 200
+
+ print "Test Result origin: ", self.resultOrig
+ print "Test Result Destination: ", self.resultDest
+ x.sendData('487')
+ y.sendData('487')
+
+ else:
+ self.testResult = 604
+ print "604 General Handler Error: Destination handler no respond"
+ #tell Caller handler to terminate because receiver doesnt work
+ x.sendData('487')
+
+ y.closeConnection()
+
+ except ValueError:
+ print "601 General Handler Error: Could not open Destination handler"
+ self.testResult = 601
+ else:
+ self.testResult = 605
+ print "605 General Handler Error: Origin handler no respond"
+
+ x.closeConnection()
+
+ except ValueError:
+ testResult = 602
+ print "602 General Handler Error: Could not open Origin handler"
+
diff --git a/For Weekly Test/Old/20-07-2011/classController.pyc b/For Weekly Test/Old/20-07-2011/classController.pyc
new file mode 100644
index 0000000..c649bdb
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classController.pyc
Binary files differ
diff --git a/For Weekly Test/Old/20-07-2011/classDB.py b/For Weekly Test/Old/20-07-2011/classDB.py
new file mode 100644
index 0000000..11a109f
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classDB.py
@@ -0,0 +1,271 @@
+import MySQLdb
+import string
+
+class DBMySQLConnection:
+ def __init__(self, username, password, host, dbname):
+ #initialize at the start all the user parameters
+ self.usern = username
+ self.passw = password
+ self.host = host
+ self.db = dbname
+ self.connectionCreated = 0
+ self.tasksList = list()
+ global debugMode
+ debugMode = 0
+
+ def connectDB(self):
+ try:
+ #try the connection
+ self.datBaseConn=MySQLdb.connect(self.host,self.usern, self.passw,self.db)
+ self.datBaseConn.paramstyle = 'format'
+ self.cur = self.datBaseConn.cursor() #make the cursor, used for sending queries
+ self.connectionCreated = 1 #use it as an indicator that the connection was created
+ return 1
+
+ except MySQLdb.Error, e:
+ #if we have an error then try to catch it
+ error=str(e)
+ if error[1:5] == '1045':
+ #wrong username or password
+ return 0
+ elif error[1:5] == '2002':
+ #can't connect to mysql, mysql shutdown or wrong host
+ return 2
+ else:
+ if debugMode == 1:
+ print error
+ return 3
+
+ def closeDBConn(self):
+ #close the connection to the database here
+ if self.connectionCreated == 1:
+ try:
+ #close the cursor and then the connection to the DB
+ self.cur.close()
+ self.datBaseConn.close()
+ return 1
+ except MySQLdb.Error, e:
+ #in case of an error
+ if debugMode == 1:
+ error = str(e)
+ print error
+ return 3
+ else:
+ #I never really had a connection
+ return 0
+
+ def anyTasksToDo(self):
+ #see are there any jobs to be executed and make a list out of it
+ if self.connectionCreated == 1:
+ try:
+ self.cur.execute("SELECT * FROM TempTaskTable")
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+ for record in output:
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+ self.tasksList.append(columns)
+ return 1
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def cleanTasksList(self):
+ if self.connectionCreated == 1:
+ del self.tasksList[:]
+ return 1
+ else:
+ return 0
+
+ def removeTaskFromList(self, taskID):
+ #remove only one task from the task list
+ if self.connectionCreated == 1:
+ for index in range(len(self.tasksList)):
+ item = self.tasksList[index]
+ if item[0] == str(taskID):
+ #self.tasksList.remove(index)
+ #print 'found it'
+ del self.tasksList[index]
+ return 1 #deleted taskID
+
+ return 2 #didn't find that taskID
+ else:
+ return 0
+
+ def deviceAddress(self,deviceName):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("SELECT `deviceIP` FROM DeviceAddress where `deviceName`=%s", deviceName)
+ #self.cur.execute()
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+ deviceAddr = ''
+ for record in output:
+ columns = list()
+ for entry in record:
+ deviceAddr = str(entry)
+ return deviceAddr
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3 #some error happened
+ else:
+ return 0 #I am not connected
+
+ def updateTaskResult(self, taskID, status):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE TaskTable SET status=%i WHERE taskID=%i"%(int(status), int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #update successful
+ else:
+ return 4 #taskID doesn't exist
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def updatePingResult(self, taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE PingResultTable SET sipServer=%i, sipGate=%i, sipLoc=%i, gsmBox1=%i, gsmBox2=%i WHERE taskNo=%i"%(int(sipServer), int(sipGate), int(sipLoc), int(gsmBox1), int(gsmBox2), int(taskNo)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #ping table updated
+ else:
+ return 4 #the taskNo didn't exist
+
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def deleteTempTask(self, taskID):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("DELETE FROM TempTaskTable WHERE taskID=%i"%(int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+
+ if successful == 1:
+ return 1 #deleted it
+ else:
+ return 4 #that taskID didn't exist or something else
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+
+ else:
+ return 0
+
+ def addResult(self, taskID, result):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("INSERT INTO ResultTable(taskID, result) VALUES ('%i', '%i')"%(int(taskID), int(result)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 1:
+ return 1 #successfully added the result
+ else:
+ return 4 #hmmm
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1062':
+ return 2 #duplicate entry for the key
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+
+ def insertTaskIn2(self, fromDevice, toDevice, taskNo):
+ if self.connectionCreated == 1:
+ try:
+ #I used here a transaction since I want the mysql to execute a few commands and tell me was it successful rather than to execute some and there happens a mistake and one part is updated and the other isn't
+ newQuery = "START TRANSACTION; INSERT INTO `TaskTable` (`taskNo`, `from`, `to`, `status`) VALUES ('" + str(taskNo) + "', '" + str(fromDevice) + "', '" + str(toDevice) +"', '0'); SELECT @taskID := LAST_INSERT_ID(); INSERT INTO `TempTaskTable` (`taskID`, `taskNo`, `from`, `to`) VALUES (@taskID, '" + str(taskNo) + "', '" + str(fromDevice) + "', '"+ str(toDevice) + "'); COMMIT;"
+
+
+ successful = self.cur.execute(newQuery)
+ output = self.cur.fetchone()
+
+
+ #without closing the cursos we get a MySQL error, the mistake is an internal mistak of the MySQLdb python library
+ # self.cur.close()
+ # self.cur = self.datBaseConn.cursor()
+
+ while self.cur.nextset() is not None: pass
+
+ newQuery1 = 'SELECT taskID FROM `TempTaskTable` ORDER BY taskID DESC LIMIT 1';
+ successful1 = self.cur.execute(newQuery1)
+ record = self.cur.fetchone()
+
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+
+ columns.append(str(taskNo))
+ columns.append(str(fromDevice))
+ columns.append(str(toDevice))
+ self.tasksList.append(columns)
+
+ return 1
+
+ if debugMode == 1:
+ print output
+
+ except MySQLdb.Error, e:
+ error = str(e)
+ if debugMode == 1:
+ print str(e)
+ if error[1:5] == '1062':
+ return 2 #duplicate entry for the key
+ return 3
+ else:
+ return 0
+
+
+ def searchTaskList(self, fromDevice, toDevice):
+ if self.connectionCreated == 1:
+ for item in self.tasksList:
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item [3]
+ if callFrom == fromDevice and callTo == toDevice:
+ return 1 #that task was found
+ return 2 #that task wasn't found
+ else:
+ return 0
diff --git a/For Weekly Test/Old/20-07-2011/classDb.pyc b/For Weekly Test/Old/20-07-2011/classDb.pyc
new file mode 100644
index 0000000..8bf4d7c
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classDb.pyc
Binary files differ
diff --git a/For Weekly Test/Old/20-07-2011/classPing.py b/For Weekly Test/Old/20-07-2011/classPing.py
new file mode 100644
index 0000000..e13b32b
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classPing.py
@@ -0,0 +1,28 @@
+import subprocess
+import string
+
+class Ping:
+
+ def __init__(self, pingAddress):
+ self.pingAddress = pingAddress
+
+ def ping(self,numberTries):
+ tried = 1
+ while numberTries >= tried:
+ tried += 1
+ #the parameter c 1 means only one ping to be sent, parameter W 3 means how many seconds the time out should be, 3 seconds
+ ping_cmd = subprocess.Popen(['ping', self.pingAddress, '-c', '1', '-W', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ unknownHost = int(string.find(ping_cmd, 'unknown host'))
+
+
+ if pingAlive != -1:
+ break
+
+ if unknownHost != -1:
+ return 2 #unknown host
+ if pingAlive != -1:
+ return 1 #ping works fine
+ else:
+ return 0 #no ping response
diff --git a/For Weekly Test/Old/20-07-2011/classPing.pyc b/For Weekly Test/Old/20-07-2011/classPing.pyc
new file mode 100644
index 0000000..b664a9c
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classPing.pyc
Binary files differ
diff --git a/For Weekly Test/Old/20-07-2011/classServer.py b/For Weekly Test/Old/20-07-2011/classServer.py
new file mode 100644
index 0000000..93c2f8e
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classServer.py
@@ -0,0 +1,152 @@
+import socket
+import sys
+import os
+import string
+import signal
+
+class TimeoutException(Exception):
+ pass
+
+class ServerHandler:
+
+ def __init__(self,p):
+ self.port = p
+ self.host = None #symbolic name meaning all available interfaces
+ self.s = None
+ self.connected = 0
+ self.address = "127.0.0.1" #address of the main controller
+ self.onceConnected = 0
+ self.error = 'No error'
+
+ self.debugMode = 0
+
+ def openSocket(self):
+ self.error = 'No error'
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC,
+ socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
+ af, socktype, proto, canonname, sa = res
+
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+
+ try:
+ self.s.bind(sa)
+ self.s.listen(1)
+ except socket.error, msg:
+ self.s.close()
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+ break
+
+ if self.s is None:
+ self.connected = 0
+ return 0
+ else: #accept the connection
+ self.connection, self.address = self.s.accept()
+ self.connected = 1
+ self.onceConnected = 1
+ return 1
+
+ def connectedTo(self):
+ return self.address
+
+ def receiveData(self, timeout):
+ if self.connected == 1:
+
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+
+ try:
+
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(timeout) #start the timeout alarm, for timeout seconds
+
+ data = self.connection.recv(1024)
+
+ #stop the timeout function
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ if not data:
+ self.connected = 0
+ return 'NO DATA'
+ else:
+ return data
+
+ except TimeoutException:
+ #timeout happened
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'TIMEOUT'
+
+ except Exception, e:
+ #stop the timeout timer
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ if error[0:11] == '[Errno 104]':
+ return 3 #the other side reset the connection,[Errno 104] Connection reset by peer
+
+ return 2
+ else:
+ return 0
+
+ def sendData(self, data):
+ if self.connected == 1:
+ try:
+ self.connection.send(data)
+ return 1
+
+ except Exception, e:
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connecected = 0
+ return 2
+ else:
+ return 0
+
+ def closeConnection(self):
+ if self.onceConnected == 1:
+ try:
+ self.connected = 0
+ SHUT_RDWR = 2
+ self.connection.shutdown(SHUT_RDWR)
+ self.connection.close()
+ return 1
+ except Exception, e:
+ self.connected = 0
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ if error[0:11] == '[Errno 107]':
+ return 3 #the other side closed the connection before us [Errno 107] Transport endpoint is not connected
+ return 2
+ else:
+ return 0
+
+ def killPort(self):
+ killResult = os.popen('lsof -i tcp:' + str(self.port) + ' | grep "python " | awk -F" " ' + "'{print $2}'").read()
+ killResult = killResult.replace('\n','')
+ print killResult
+ if killResult!='':
+ print killResult
+ killPort = os.popen("kill -9 " + killResult).read()
+ return 1
+ return 0
diff --git a/For Weekly Test/Old/20-07-2011/classServer.pyc b/For Weekly Test/Old/20-07-2011/classServer.pyc
new file mode 100644
index 0000000..a96a41f
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/classServer.pyc
Binary files differ
diff --git a/For Weekly Test/Old/20-07-2011/gsmcall_.py b/For Weekly Test/Old/20-07-2011/gsmcall_.py
new file mode 100644
index 0000000..70e9c72
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/gsmcall_.py
@@ -0,0 +1,105 @@
+import sys
+import socket
+import time
+
+import subprocess
+import os
+from serial import *
+
+import classServer
+
+from time import sleep
+import string
+
+
+stop ="false"
+success = "failed"
+
+global server
+
+global ser
+portAddress = '/dev/ttyUSB0'
+portName = portAddress[-4:]
+portExist = os.popen('dmesg | grep ' + portName).read()
+
+if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+
+
+while stop <> "true":#???
+
+
+ try:
+
+ server = classServer.ServerHandler(50098)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ server.sendData('ready')#send message to controller
+ print "Controller status: ", server.connected
+
+
+ while stop <> "true":
+ try:
+ data = server.receiveData() # waiting mode, until receiver start message or terminate message
+
+ if data == "start": # if receiver start message, handler start to call destination
+
+ while 1:
+
+ num = server.receiveData()
+
+ #num = "929"
+ if num <> "NO DATA":
+ server.closeConnection()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+ ser.close()
+ ser.open()
+
+ ser.write('ATD4661' + num + ';\r')
+ sleep(3)
+ ser.write('AT+CHUP\r')
+
+ ser.close()
+ tried = server.openSocket()
+ sleep(2)
+ success = "success"
+ server.sendData(success)
+
+ if data == "terminated": # will terminate the handler if controller send terminate message
+ stop = "true"
+ break
+
+ except ValueError:
+ print "error when sending message"
+ server.closeConnection()
+ del server
+
+
+ server.closeConnection()
+ del server
+ print "Goodbye"
+ sleep(3)
+ sys.exit(1)
+
+ except ValueError:
+ print "Exception: " + str(e)
+
+print "Goodbye"
+sleep(3)
diff --git a/For Weekly Test/Old/20-07-2011/gsmincom_.py b/For Weekly Test/Old/20-07-2011/gsmincom_.py
new file mode 100644
index 0000000..0b2c48e
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/gsmincom_.py
@@ -0,0 +1,148 @@
+
+import atexit
+import signal
+
+import sys
+import socket
+import time
+import os
+import string
+import classServer
+from time import sleep
+from serial import *
+
+
+success = None
+stop = False
+
+try:
+
+ global ser
+ global server
+ portAddress = '/dev/ttyUSB0'
+ portName = portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+
+
+ server = classServer.ServerHandler(50105)
+ tried = server.openSocket()
+
+
+ print "here:", server.connected
+ if server.connected == 1:
+
+ server.sendData('ready')
+ server.closeConnection()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+ ser.close()
+ ser.open()
+
+ signalQuality = ser.write('AT+CSQ\r')
+ print "signal Quality ", signalQuality
+ print ""
+
+
+
+ while stop <> True:
+
+ global pickUp
+ pickUp = None
+ buffer = ""
+
+
+ buffer = buffer + ser.read(ser.inWaiting()) #read the serial port and add it to the buffer variable
+ if '\n' in buffer: #if a new line character is found in the buffer then the cellphone has sent something
+ lines = buffer.split('\n') #parse the buffer variable with the new line character
+ last_received = lines.pop(0) #put into last_received variable the first content from lines (FIFO)
+
+ buffer = '\n'.join(lines) #add a new line to the buffer variable
+
+ last_received=last_received.split('\n') #parse the last received value with new lines
+ line = last_received[0].replace(chr(13), '')
+
+ print "buffer:", buffer
+ print "line:", line
+
+ if len(line) > 0:
+
+
+ if line=="RING":
+
+ print "Somebody calling"
+ print ""
+ sleep(1)
+ ser.write('ATA\r')
+ sleep(1)
+ ser.write('AT+CSQ\r')
+
+ sleep(2)
+ ser.write('AT+CLCC\r')
+
+
+ if line[0:5] == '+CSQ:':
+
+ space = int(string.find(line,' '))+1
+ coma = int(string.find(line,','))
+ signalStr = (int(line[space:coma])*2)-113
+
+ line=''
+
+ if line[0:6]=='+CLCC:':
+
+ pickUp = 1
+
+ print "I will hangup the call"
+ print ""
+ sleep(5)
+
+ ser.write('AT+CHUP\r')
+ pickUp = 0
+ ser.close()
+
+ quotation1 = int(string.find(line,'"'))+1
+ lineTemp = line[quotation1:]
+
+ quotation2 = int(string.find(lineTemp,'"'))
+ numberOfCaller = line[quotation1:quotation1+quotation2]
+
+ print "Signal Strength: ", signalStr
+ print ""
+
+ tried = server.openSocket()
+ server.sendData('I got call from :' +numberOfCaller)
+ print "with caller number", numberOfCaller
+ sleep(1)
+ server.sendData('success')
+ stop = True
+ sleep (3)
+
+
+
+ server.closeConnection()
+ del server
+ else:
+
+ print "not connected"
+
+ del server
+
+ ser.close()
+except ValueError:
+ print "Exception: "
+ server.closeConnection()
+ del server
+
+print "GOODBYE"
+sleep(5)
diff --git a/For Weekly Test/Old/20-07-2011/landlineCall.py b/For Weekly Test/Old/20-07-2011/landlineCall.py
new file mode 100644
index 0000000..fcdf4fe
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/landlineCall.py
@@ -0,0 +1,135 @@
+import sys
+import pjsua as pj
+import classServer
+import LogFileClass
+logger = LogFileClass.Logging('landlineCallHandler.log')
+from time import sleep
+
+
+def log_cb(level, str, len):
+ print str, "landline log"
+
+# Receive events from Call
+class MyCallCallback(pj.CallCallback):
+
+ def on_state(self):
+ global current_call
+
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ if self.call.info().state_text == "CONNECTING":
+ logger.logEvent("Call Connecting")
+ sleep(1)
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ logger.logEvent("will Hangup call")
+ current_call.hangup()
+
+ logger.logEvent('200')
+ server.sendData('200')
+ else:
+ sleep(0.5)
+
+ if self.call.info().last_reason == "Busy Here":
+ logger.logEvent('Number busy or Offline')
+ server.sendData('486')
+ logger.logEvent('486')
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ logger.logEvent('Call Disconnected')
+ current_call = None
+
+
+def make_call(uri):
+
+ try:
+
+ cb=MyCallCallback()
+ return acc.make_call(uri, cb)
+
+ except pj.Error, e:
+ print "408 " + str(e)
+ logger.logEvent('408')
+ return None
+
+
+lib = pj.Lib()
+stop =False
+current_call = None
+logger.logEvent('')
+
+while stop <> True:
+
+
+ lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+ server = classServer.ServerHandler(50099)
+ logger.logEvent('Connect to Controller via port 50099')
+ conn = server.openSocket()
+
+ try:
+ logger.logEvent('Register Account to sipgate.de server')
+ acc_cfg = pj.AccountConfig("sipgate.de","1289459","MMW9AX")
+ acc = lib.create_account(acc_cfg, cb=pj.AccountCallback())
+
+
+ if acc.info().reg_status < 700:
+
+ server.sendData('ready')
+ logger.logEvent('Handler Ready')
+
+ while 1:
+ try:
+ data = server.receiveData(0)
+ event = data[0:5]
+ num = data[6:]
+
+ if event == "start" and num <> "":
+
+ logger.logEvent(event)
+ logger.logEvent('Make a call to: ' + num)
+ number = "sip:"+num+"@sipgate.de"
+ current_call = make_call(number)
+
+ if data == "487":
+ stop = True
+ logger.logEvent('Terminate')
+ break
+
+ except ValueError:
+ logger.logEvent("error: Failed retrive message from Controller")
+ logger.logEvent('999')
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+ else:
+ logger.logEvent("488 Not Acceptable Here")
+
+ lib.destroy()
+ lib = None
+ acc = None
+
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+ except ValueError:
+ print "401 Unauthorized " + str(e)
+ logger.logEvent("401 Unauthorized ")
+
+logger.logEvent("Goodbye")
+sleep(3)
+acc.delete()
+logger.logEvent('Un-Rigester SIP Account')
+lib.destroy()
+server.closeConnection()
+logger.logEvent('Close Connection to the Controller')
+lib = None
+acc = None
+
diff --git a/For Weekly Test/Old/20-07-2011/landlineReceiver.py b/For Weekly Test/Old/20-07-2011/landlineReceiver.py
new file mode 100644
index 0000000..ba02562
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/landlineReceiver.py
@@ -0,0 +1,111 @@
+import sys
+import pjsua as pj
+import classServer
+import LogFileClass
+
+from time import sleep
+
+logger = LogFileClass.Logging('LandlineRecHandler.log')
+
+def log_cb(level, str, len):
+ print str, "landline Handler Receiver Log"
+
+
+class MyAccountCallback(pj.AccountCallback):
+
+ def on_incoming_call(self, call):
+
+ current_call = call
+ logger.logEvent(current_call)
+ sleep(0.5)
+
+ call.answer(200)
+ logger.logEvent("Answer call")
+ sleep(0.5)
+
+ if current_call <> None:
+ logger.logEvent("Hangup call")
+ call.hangup()
+
+ server.sendData('200')
+ logger.logEvent('200')
+lib = pj.Lib()
+stop = False
+logger.logEvent('')
+
+try:
+
+ server = classServer.ServerHandler(50106)
+ logger.logEvent('Connect to Controller via port 50106')
+ conn = server.openSocket()
+
+ lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+ try:
+ logger.logEvent('Register Account to sipgate.de server')
+ acc_cfg = pj.AccountConfig("sipgate.de","1289459","MMW9AX")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+ if acc.info().reg_status < 700:
+
+ logger.logEvent(acc.info().reg_status)
+ server.sendData('ready')
+ logger.logEvent('Handler Ready')
+
+ while stop <> True:
+
+ data = server.receiveData(0)
+
+ if data == "487":
+ logger.logEvent('Terminate')
+ stop = True
+ break
+
+ transport = None
+ acc.delete()
+ logger.logEvent('Un-Rigester SIP Account')
+ acc = None
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+ else:
+ logger.logEvent("488 Not Acceptable Here")
+ lib.destroy()
+
+ lib = None
+ acc = None
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+
+ except pj.Error, e:
+ print "401 Unauthorized " +str(e)
+ logger.logEvent("401 Unauthorized ")
+
+ lib.destroy()
+ lib = None
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ logger.logEvent(str(e))
+
+ lib.destroy()
+
+ lib = None
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+
+
+
+
diff --git a/For Weekly Test/Old/20-07-2011/localsipReceiver.py b/For Weekly Test/Old/20-07-2011/localsipReceiver.py
new file mode 100644
index 0000000..eb95ce0
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/localsipReceiver.py
@@ -0,0 +1,112 @@
+import sys
+import pjsua as pj
+import classServer
+import LogFileClass
+
+from time import sleep
+
+logger = LogFileClass.Logging('UniSIPRecHandler.log')
+
+def log_cb(level, str, len):
+ print str, "SIP University account Handler Receiver Log"
+
+
+class MyAccountCallback(pj.AccountCallback):
+
+ def on_incoming_call(self, call):
+
+ current_call = call
+ logger.logEvent(current_call)
+ sleep(0.5)
+
+ call.answer(200)
+ logger.logEvent("Answer call")
+ sleep(0.5)
+
+ if current_call <> None:
+ logger.logEvent("Hangup call")
+ call.hangup()
+
+ server.sendData('200')
+ logger.logEvent('200')
+lib = pj.Lib()
+stop = False
+logger.logEvent('')
+
+try:
+
+ server = classServer.ServerHandler(50107)
+ logger.logEvent('Connect to Controller via port 50107')
+ conn = server.openSocket()
+
+ lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+ try:
+ logger.logEvent('Register Account to University SIP server')
+ acc_cfg = pj.AccountConfig("132.230.252.228", "4976120397897", "hB8M3WyFt61C")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+ if acc.info().reg_status < 700:
+
+ logger.logEvent(acc.info().reg_status)
+ sleep(5)
+ server.sendData('ready')
+ logger.logEvent('Handler Ready')
+
+ while stop <> True:
+
+ data = server.receiveData(0)
+
+ if data == "487":
+ logger.logEvent('Terminate')
+ stop = True
+ break
+
+ transport = None
+ acc.delete()
+ logger.logEvent('Un-Rigester SIP Account')
+ acc = None
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+ else:
+ logger.logEvent("488 Not Acceptable Here")
+ lib.destroy()
+
+ lib = None
+ acc = None
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+
+ except pj.Error, e:
+ print "401 Unauthorized " +str(e)
+ logger.logEvent("401 Unauthorized ")
+
+ lib.destroy()
+ lib = None
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ logger.logEvent(str(e))
+
+ lib.destroy()
+
+ lib = None
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+
+
+
+
diff --git a/For Weekly Test/Old/20-07-2011/sipCall.py b/For Weekly Test/Old/20-07-2011/sipCall.py
new file mode 100644
index 0000000..51ae240
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/sipCall.py
@@ -0,0 +1,135 @@
+import sys
+import pjsua as pj
+import classServer
+import LogFileClass
+logger = LogFileClass.Logging('sipCallHandler.log')
+from time import sleep
+
+
+def log_cb(level, str, len):
+ print str, "SIP log"
+
+# Receive events from Call
+class MyCallCallback(pj.CallCallback):
+
+ def on_state(self):
+ global current_call
+
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ if self.call.info().state_text == "CONNECTING":
+ logger.logEvent("Call Connecting")
+ sleep(1)
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ logger.logEvent("will Hangup call")
+ current_call.hangup()
+
+ logger.logEvent('200')
+ server.sendData('200')
+ else:
+ sleep(0.5)
+
+ if self.call.info().last_reason == "Busy Here":
+ logger.logEvent('Number busy or Offline')
+ server.sendData('486')
+ logger.logEvent('486')
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ logger.logEvent('Call Disconnected')
+ current_call = None
+
+
+def make_call(uri):
+
+ try:
+
+ cb=MyCallCallback()
+ return acc.make_call(uri, cb)
+
+ except pj.Error, e:
+ print "408 " + str(e)
+ logger.logEvent('408')
+ return None
+
+
+lib = pj.Lib()
+stop =False
+current_call = None
+logger.logEvent('')
+
+while stop <> True:
+
+
+ lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+ server = classServer.ServerHandler(50097)
+ logger.logEvent('Connect to Controller via port 50097')
+ conn = server.openSocket()
+
+ try:
+ logger.logEvent('Register Account to SIP server')
+ acc_cfg = pj.AccountConfig("132.230.4.8","mpselftest1","1mpselftest")
+ acc = lib.create_account(acc_cfg, cb=pj.AccountCallback())
+
+
+ if acc.info().reg_status < 700:
+
+ server.sendData('ready')
+ logger.logEvent('Handler Ready')
+
+ while 1:
+ try:
+ data = server.receiveData(0)
+ event = data[0:5]
+ num = data[6:]
+
+ if event == "start" and num <> "":
+
+ logger.logEvent(event)
+ logger.logEvent('Make a call to: ' + num)
+ number = "sip:"+num+"@132.230.4.8"
+ current_call = make_call(number)
+
+ if data == "487":
+ stop = True
+ logger.logEvent('Terminate')
+ break
+
+ except ValueError:
+ logger.logEvent("error: Failed retrive message from Controller")
+ logger.logEvent('999')
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+ else:
+ logger.logEvent("488 Not Acceptable Here")
+
+ lib.destroy()
+ lib = None
+ acc = None
+
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+ except ValueError:
+ print "401 Unauthorized " + str(e)
+ logger.logEvent("401 Unauthorized ")
+
+logger.logEvent("Goodbye")
+sleep(3)
+acc.delete()
+logger.logEvent('Un-Rigester SIP Account')
+lib.destroy()
+server.closeConnection()
+logger.logEvent('Close Connection to the Controller')
+lib = None
+acc = None
+
diff --git a/For Weekly Test/Old/20-07-2011/sipCallHandler.log b/For Weekly Test/Old/20-07-2011/sipCallHandler.log
new file mode 100644
index 0000000..88005da
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/sipCallHandler.log
@@ -0,0 +1,112 @@
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:15:05.342369 ------------------
+On: 2011-07-19 13:15:05.351935 Event: Connect to Controller via port 50097
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:15:19.499982 ------------------
+On: 2011-07-19 13:15:19.509715 Event: Connect to Controller via port 50097
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:15:26.475769 ------------------
+On: 2011-07-19 13:15:26.485197 Event: Connect to Controller via port 50097
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:15:36.151728 ------------------
+On: 2011-07-19 13:15:36.162183 Event: Connect to Controller via port 50097
+On: 2011-07-19 13:15:41.003034 Event: Register Account to SIP server
+On: 2011-07-19 13:15:41.003725 Event: Handler Ready
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:17:12.303046 ------------------
+On: 2011-07-19 13:17:12.315193 Event: Connect to Controller via port 50097
+On: 2011-07-19 13:17:17.153546 Event: Register Account to SIP server
+On: 2011-07-19 13:17:17.154274 Event: Handler Ready
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:17:35.665110 ------------------
+On: 2011-07-19 13:17:35.675358 Event: Connect to Controller via port 50097
+On: 2011-07-19 13:17:40.499101 Event: Register Account to SIP server
+On: 2011-07-19 13:17:40.499773 Event: Handler Ready
+On: 2011-07-19 13:17:40.499834 Event: status Server
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:17:52.086222 ------------------
+On: 2011-07-19 13:17:52.096731 Event: Connect to Controller via port 50097
+On: 2011-07-19 13:17:56.885712 Event: Register Account to SIP server
+On: 2011-07-19 13:17:56.886499 Event: Handler Ready
+On: 2011-07-19 13:17:56.886560 Event: status Server
+On: 2011-07-19 13:18:03.923972 Event: start
+On: 2011-07-19 13:18:03.924059 Event: Make a call to: 076120397897
+On: 2011-07-19 13:18:04.476832 Event: Call Connecting
+On: 2011-07-19 13:18:05.477602 Event: will Hangup call
+On: 2011-07-19 13:18:05.477915 Event: 200
+On: 2011-07-19 13:18:05.478784 Event: 487
+On: 2011-07-19 13:18:05.478854 Event: Terminate
+On: 2011-07-19 13:18:05.479006 Event: Close Connection to the Controller
+On: 2011-07-19 13:18:05.479098 Event: Close Connection to the Controller
+On: 2011-07-19 13:18:05.479125 Event: Goodbye
+On: 2011-07-19 13:18:05.980151 Event: Call Disconnected
+On: 2011-07-19 13:18:08.482562 Event: Un-Rigester SIP Account
+On: 2011-07-19 13:18:10.007436 Event: Close PJSUA Library
+On: 2011-07-19 13:18:10.007616 Event: Close Connection to the Controller
+
+
+------------------STARTED THE LOGGING 2011-07-19 13:39:56.727710 ------------------
+On: 2011-07-19 13:39:56.741089 Event: Connect to Controller via port 50097
+On: 2011-07-19 13:40:01.558882 Event: Register Account to SIP server
+On: 2011-07-19 13:40:01.559560 Event: Handler Ready
+On: 2011-07-19 13:40:08.589980 Event: start
+On: 2011-07-19 13:40:08.590047 Event: Make a call to: 076120397897
+On: 2011-07-19 13:40:09.142686 Event: Call Connecting
+On: 2011-07-19 13:40:10.144021 Event: will Hangup call
+On: 2011-07-19 13:40:10.144344 Event: 200
+On: 2011-07-19 13:40:10.145325 Event: Terminate
+On: 2011-07-19 13:40:10.145583 Event: Close Connection to the Controller
+On: 2011-07-19 13:40:10.145717 Event: Close Connection to the Controller
+On: 2011-07-19 13:40:10.145766 Event: Goodbye
+On: 2011-07-19 13:40:10.646310 Event: Call Disconnected
+On: 2011-07-19 13:40:13.149215 Event: Un-Rigester SIP Account
+On: 2011-07-19 13:40:14.675876 Event: Close Connection to the Controller
+
+
+------------------STARTED THE LOGGING 2011-07-19 14:08:43.478088 ------------------
+On: 2011-07-19 14:08:43.488948 Event: Connect to Controller via port 50097
+On: 2011-07-19 14:08:48.312081 Event: Register Account to SIP server
+On: 2011-07-19 14:08:48.312787 Event: Handler Ready
+On: 2011-07-19 14:08:50.341066 Event: start
+On: 2011-07-19 14:08:50.341103 Event: Make a call to: 076145875681
+On: 2011-07-19 14:08:55.437133 Event: Call Connecting
+On: 2011-07-19 14:08:56.438035 Event: will Hangup call
+On: 2011-07-19 14:08:56.438314 Event: 200
+On: 2011-07-19 14:08:56.439496 Event: Terminate
+On: 2011-07-19 14:08:56.439679 Event: Close Connection to the Controller
+On: 2011-07-19 14:08:56.439788 Event: Close Connection to the Controller
+On: 2011-07-19 14:08:56.439832 Event: Goodbye
+On: 2011-07-19 14:08:56.940779 Event: Call Disconnected
+On: 2011-07-19 14:08:59.441807 Event: Un-Rigester SIP Account
+On: 2011-07-19 14:09:00.553758 Event: Close Connection to the Controller
+
+
+------------------STARTED THE LOGGING 2011-07-19 14:11:06.310465 ------------------
+On: 2011-07-19 14:11:06.324540 Event: Connect to Controller via port 50097
+On: 2011-07-19 14:11:06.325868 Event: Register Account to SIP server
+On: 2011-07-19 14:11:06.326082 Event: Handler Ready
+
+
+------------------STARTED THE LOGGING 2011-07-19 14:10:53.811684 ------------------
+On: 2011-07-19 14:10:53.825926 Event: Connect to Controller via port 50097
+On: 2011-07-19 14:10:58.642116 Event: Register Account to SIP server
+On: 2011-07-19 14:10:58.642823 Event: Handler Ready
+On: 2011-07-19 14:11:00.667479 Event: start
+On: 2011-07-19 14:11:00.667554 Event: Make a call to: 076145875681
+On: 2011-07-19 14:11:05.148098 Event: Call Connecting
+On: 2011-07-19 14:11:06.149414 Event: will Hangup call
+On: 2011-07-19 14:11:06.149749 Event: 200
+On: 2011-07-19 14:11:06.151074 Event: Terminate
+On: 2011-07-19 14:11:06.151273 Event: Close Connection to the Controller
+On: 2011-07-19 14:11:06.151408 Event: Close Connection to the Controller
+On: 2011-07-19 14:11:06.151457 Event: Goodbye
+On: 2011-07-19 14:11:06.652364 Event: Call Disconnected
+On: 2011-07-19 14:11:09.153186 Event: Un-Rigester SIP Account
+On: 2011-07-19 14:11:10.309656 Event: Close Connection to the Controller
diff --git a/For Weekly Test/Old/20-07-2011/sipReceiver.py b/For Weekly Test/Old/20-07-2011/sipReceiver.py
new file mode 100644
index 0000000..62f9a49
--- /dev/null
+++ b/For Weekly Test/Old/20-07-2011/sipReceiver.py
@@ -0,0 +1,111 @@
+import sys
+import pjsua as pj
+import classServer
+import LogFileClass
+
+from time import sleep
+
+logger = LogFileClass.Logging('sipRecHandler.log')
+
+def log_cb(level, str, len):
+ print str, "sip Handler Receiver Log"
+
+
+class MyAccountCallback(pj.AccountCallback):
+
+ def on_incoming_call(self, call):
+
+ current_call = call
+ logger.logEvent(current_call)
+ sleep(0.5)
+
+ call.answer(200)
+ logger.logEvent("Answer call")
+ sleep(0.5)
+
+ if current_call <> None:
+ logger.logEvent("Hangup call")
+ call.hangup()
+
+ server.sendData('200')
+ logger.logEvent('200')
+lib = pj.Lib()
+stop = False
+logger.logEvent('')
+
+try:
+
+ server = classServer.ServerHandler(50104)
+ logger.logEvent('Connect to Controller via port 50104')
+ conn = server.openSocket()
+
+ lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+ try:
+ logger.logEvent('Register Account to SIP Asterik server')
+ acc_cfg = pj.AccountConfig("132.230.4.8", "mpselftest2", "2mpselftest")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+ if acc.info().reg_status < 700:
+
+ logger.logEvent(acc.info().reg_status)
+ server.sendData('ready')
+ logger.logEvent('Handler Ready')
+
+ while stop <> True:
+
+ data = server.receiveData(0)
+
+ if data == "487":
+ logger.logEvent('Terminate')
+ stop = True
+ break
+
+ transport = None
+ acc.delete()
+ logger.logEvent('Un-Rigester SIP Account')
+ acc = None
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+ else:
+ logger.logEvent("488 Not Acceptable Here")
+ lib.destroy()
+
+ lib = None
+ acc = None
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+
+ except pj.Error, e:
+ print "401 Unauthorized " +str(e)
+ logger.logEvent("401 Unauthorized ")
+
+ lib.destroy()
+ lib = None
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ logger.logEvent(str(e))
+
+ lib.destroy()
+
+ lib = None
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+
+
+
+
diff --git a/For Weekly Test/Old/23-07-2011/2classController.py b/For Weekly Test/Old/23-07-2011/2classController.py
new file mode 100644
index 0000000..c722df3
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/2classController.py
@@ -0,0 +1,141 @@
+import sys
+import os
+import subprocess
+
+import classClient
+import classDb
+import classPing
+
+import LogFileClass
+logger = LogFileClass.Logging('2classController.log')
+
+from time import sleep
+
+
+class test:
+
+ def __init__(self, orig, dest, destNo):
+ self.orig = orig
+ self.dest = dest
+ self.destNo = destNo
+ self.repeatTest = None
+ self.portOrig = None
+ self.portDest = None
+ self.resultOrig = None
+ self.resultDest = None
+ self.testResult = None
+ self.add = None
+
+ def FuncTest(self):
+
+ logger.logEvent('')
+
+ try:
+
+ if self.orig =="RZ1":
+ self.portOrig = 50095
+ self.add = ''
+
+ elif self.orig =="RZ2":
+ self.portOrig = 50096
+ self.add = ''
+
+ elif self.orig =="RZ3":
+ self.portOrig = 50097
+ self.add = ''
+
+ else:
+ self.portOrig = 50099
+ self.add = 'localhost'
+ #command='--command=python 2sipHandler.py '+self.orig+ ' ' +str(self.portOrig)
+ subprocess.Popen(args=["gnome-terminal", '--command=python 2sipHandler.py '+self.orig+ ' ' +str(self.portOrig)])
+
+ sleep(3)
+
+ caller = classClient.Connection(self.add,self.portOrig)
+
+ caller.connect()
+ caller.sendData('CALLER|'+self.destNo)
+
+ origHandler = caller.receiveData(60)
+
+ if origHandler == "ready":
+ logger.logEvent('Caller handler : Ready')
+ try:
+
+ if self.dest =="gsmBox1":
+ self.portDest = 50102
+ self.add = ''
+
+ if self.dest =="gsmBox2":
+ self.portDest = 50103
+ self.add = ''
+
+ if self.dest =="gsmBox3":
+ self.portDest = 50103
+ self.add = ''
+
+ else:
+ self.portDest = 50100
+ #command='--command=python 2sipHandler.py '+self.dest+ ' ' +str(self.portDest)
+ subprocess.Popen(args=['gnome-terminal', '--command=python 2sipHandler.py '+self.dest+ ' ' +str(self.portDest)])
+ sleep(3)
+
+ receiver = classClient.Connection('localhost', self.portDest)
+
+ receiver.connect()
+ receiver.sendData('RECEIVER')
+
+ destHandler = receiver.receiveData(0)
+
+ if destHandler == 'ready':
+
+ caller.sendData('start')
+
+ self.resultOrig = caller.receiveData(60)
+ self.resultDest = receiver.receiveData(60)
+
+ if self.resultOrig <> 200 or self.resultDest <> 200:
+
+ caller.sendData('start')
+
+ self.resultOrig = caller.receiveData(60)
+ self.resultDest = receiver.receiveData(60)
+
+ if self.resultOrig <> 200 or self.resultDest <> 200:
+ self.testResult = 486
+ self.repeatTest = True
+ else:
+ self.testResult = 200
+
+ caller.sendData('487')
+ receiver.sendData('487')
+
+ else:
+
+ self.testResult = 200
+ caller.sendData('487')
+ receiver.sendData('487')
+
+ else:
+ self.testResult = 604
+ logger.logEvent('604 General Handler Error: Destination handler no respond timeout')
+ caller.sendData('487')
+
+ receiver.closeConnection()
+
+ except ValueError:
+ logger.logEvent('601 General Handler Error: Could not open Destination handler')
+ self.testResult = 601
+ caller.sendData('487')
+ caller.closeConnection()
+ else:
+ self.testResult = 605
+ logger.logEvent('605 General Handler Error: Origin handler no respond timeout')
+
+ caller.closeConnection()
+
+ except ValueError:
+ self.testResult = 602
+ logger.logEvent('602 General Handler Error: Could not open Origin handler')
+
diff --git a/For Weekly Test/Old/23-07-2011/2sipHandler.py b/For Weekly Test/Old/23-07-2011/2sipHandler.py
new file mode 100644
index 0000000..91e3f62
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/2sipHandler.py
@@ -0,0 +1,182 @@
+import sys
+import string
+import pjsua as pj
+import classServer
+import LogFileClass
+
+from time import sleep
+
+def log_cb(level, str, len):
+ print "--------starting Handler--------"
+
+# Receive events from incoming Call
+class Account(pj.AccountCallback):
+
+ def on_incoming_call(self, call):
+ global current_call
+
+ current_call = call
+ call_cb = Calling(current_call)
+ current_call.set_callback(call_cb)
+
+ logger.logEvent(current_call)
+ sleep(0.5)
+
+ call.answer(200)
+ logger.logEvent("Answer call")
+ sleep(0.5)
+
+ if current_call <> None:
+ logger.logEvent("Hangup call")
+ call.hangup()
+
+ logger.logEvent('200')
+
+class Calling(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+ def on_state(self):
+ global current_call
+
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ if self.call.info().state_text == "CONNECTING":
+ logger.logEvent("Call Connecting")
+ logger.logEvent('200')
+ server.sendData('200')
+
+ if self.call.info().last_reason == "Busy Here":
+ logger.logEvent('Number busy or Offline')
+ server.sendData('486')
+ logger.logEvent('486')
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ logger.logEvent('Call Disconnected')
+ current_call = None
+
+
+def make_call(uri):
+
+ try:
+
+ cb=Calling()
+ return acc.make_call(uri, cb)
+
+ except pj.Error, e:
+ print "408 " + str(e)
+ logger.logEvent('408')
+ return None
+
+global acc_cfg
+global handler
+global state
+
+handler = sys.argv[1]
+port = sys.argv[2]
+
+lib = pj.Lib()
+stop = False
+
+logger = LogFileClass.Logging('sipHandler.log')
+logger.logEvent('')
+
+while stop <> True:
+
+ acc_cfg = None
+
+ lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+ server = classServer.ServerHandler(port)
+ logger.logEvent('Connect to Controller')
+ conn = server.openSocket()
+
+ message = server.receiveData(30)
+ num = message[7:]
+
+ if handler == 'sip':
+ logger.logEvent('Beeing SIP')
+ acc_cfg = pj.AccountConfig("132.230.4.8","mpselftest1","1mpselftest")
+
+ elif handler == 'landline':
+ logger.logEvent('Beeing Landline')
+ acc_cfg = pj.AccountConfig("sipgate.de","1289459","MMW9AX")
+
+ elif handler == 'unisip':
+ logger.logEvent('Beeing University SIP')
+ acc_cfg = pj.AccountConfig("132.230.252.228", "4976120397897", "hB8M3WyFt61C")
+
+ else:
+ logger.logEvent('Unknown Message')
+ server.sendData('Unknown Message')
+ server.closeConnection()
+ sys.exit(1)
+
+ try:
+
+ logger.logEvent('Register Account to SIP server')
+ acc = lib.create_account(acc_cfg, cb=Account())
+
+
+ if acc.info().reg_status < 700:
+
+ if message.find('RECEIVER') <> -1:
+ logger.logEvent(acc.info().reg_status)
+ server.sendData('ready')
+ logger.logEvent('Receiver Handler Ready')
+
+ while 1:
+
+ data = server.receiveData(3)
+
+ if data == "487":
+ logger.logEvent('Terminate')
+ stop = True
+ break
+
+ elif message.find('CALLER') <> -1:
+ logger.logEvent(acc.info().reg_status)
+ server.sendData('ready')
+ logger.logEvent('Caller Handler Ready')
+
+ while 1:
+
+ data = server.receiveData(3)
+
+ if event == "start" and num <> "":
+
+ logger.logEvent(event)
+ logger.logEvent('Make a call to: ' + num)
+ number = "sip:"+num+"@132.230.4.8"
+ make_call(number)
+
+ if data == "487":
+ stop = True
+ logger.logEvent('Terminate')
+ break
+
+ else:
+ logger.logEvent('Unknow Message')
+ server.sendData('Unknow Message')
+ server.closeConnection()
+ sys.exit(1)
+
+ else:
+ logger.logEvent("488 Not Acceptable Here")
+ lib.destroy()
+
+ except ValueError:
+ print "401 Unauthorized " + str(e)
+ logger.logEvent("401 Unauthorized ")
+
+logger.logEvent("Goodbye")
+acc.delete()
+lib.destroy()
+server.closeConnection()
+lib = None
+acc = None
+
diff --git a/For Weekly Test/Old/23-07-2011/Controller.py b/For Weekly Test/Old/23-07-2011/Controller.py
new file mode 100644
index 0000000..b30ee6f
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/Controller.py
@@ -0,0 +1,54 @@
+import sys
+import classClient
+import classDb
+import 2classController
+import classCheck
+from time import sleep
+
+
+db = classDb.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
+db.connectDB()
+dbStatus = db.connectDB()
+
+
+if dbStatus == 1:
+
+ db.anyTasksToDo()
+
+ 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
+
+ call = classCheck(callFrom)
+ rec = classCheck(callTo)
+
+ if call.serverStatus <> 0:
+
+ if rec.serverStatus <> 0:
+
+ makeTest = classController.test(callFrom, callTo,rec.destNumber)
+ makeTest.FuncTest()
+
+ db.addResult(taskID, makeTest.testResult)
+
+ if makeTest.repeatTest == True:
+ db.insertTaskIn2(callTo,callFrom,taskNo)
+ else:
+ print "[failed] 500 "+callTo+ " Server Internal Error"
+ else:
+ print "[failed] 500 "+callFrom+ " Server Internal Error"
+
+ call = None
+ rec = None
+
+# will exit if DB connection failed
+else:
+ sys.exit(5)
+
diff --git a/For Weekly Test/Old/23-07-2011/LogFileClass.py b/For Weekly Test/Old/23-07-2011/LogFileClass.py
new file mode 100644
index 0000000..cb152f4
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/LogFileClass.py
@@ -0,0 +1,21 @@
+import string
+import datetime
+
+class Logging:
+
+ def __init__(self, logFileName):
+ self.writeToFile = open(logFileName, 'a')
+ self.justStarted = 1
+
+ def logEvent(self, event):
+ now = str(datetime.datetime.now())
+ if self.justStarted == 1:
+ self.writeToFile.write('\n\n------------------STARTED THE LOGGING '+ now + ' ------------------\n')
+ self.justStarted = 0
+ else:
+ self.writeToFile.write('On: '+ now + '\t' + 'Event: ' +str(event) + '\n')
+
+ def closeLogging(self):
+ now = str(datetime.datetime.now())
+ self.writeToFile.write('------------------FINISHED THE LOGGING '+ now + ' ------------------')
+ self.writeToFile.close()
diff --git a/For Weekly Test/Old/23-07-2011/LogFileClass.pyc b/For Weekly Test/Old/23-07-2011/LogFileClass.pyc
new file mode 100644
index 0000000..579ddb6
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/LogFileClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/23-07-2011/Testing.py b/For Weekly Test/Old/23-07-2011/Testing.py
new file mode 100644
index 0000000..34316ee
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/Testing.py
@@ -0,0 +1,44 @@
+import sys
+import os
+import time
+import MySQLdb
+import subprocess
+import signal
+
+import classClient
+import classDb
+import classPing
+
+from time import sleep
+
+command="--command=python sipCall.py"
+subprocess.Popen(args=["gnome-terminal", command])
+sleep(5)
+x = classClient.Connection("localhost", "50097")
+x.connect()
+origHandler = x.receiveData(0)
+print origHandler
+
+#command="--command=python localsipReceiver.py"
+#subprocess.Popen(args=["gnome-terminal", command])
+sleep(5)
+y = classClient.Connection("localhost", "50107")
+y.connect()
+
+while 1:
+ destHandler = y.receiveData(0)
+ if destHandler <> "":
+ break
+
+print destHandler
+
+if destHandler == "ready":
+ y.closeConnection()
+ y.connect()
+
+ #x.sendData("start|076120397897")
+while 1:
+ destHandlers = y.receiveData(0)
+ #origHandlers = x.receiveData(0)
+
+ print destHandlers#, origHandlers
diff --git a/For Weekly Test/Old/23-07-2011/classCheck.py b/For Weekly Test/Old/23-07-2011/classCheck.py
new file mode 100644
index 0000000..4009669
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classCheck.py
@@ -0,0 +1,28 @@
+
+import classPing
+
+class checking:
+
+ def __init__(self, handler):
+
+ self.handler = handler
+ self.destNumber = None
+ self.serverStatus = None
+
+ if self.handler == 'landline':
+ server = classPing.Ping('sipgate.de')
+ self.serverStatus = server.ping(3)
+ self.destNumber = '076145875681'
+
+ if self.handler == 'sip':
+ server = classPing.Ping('132.230.4.8')
+ self.serverStatus = server.ping(3)
+ self.destNumber = '4661928'
+
+ if self.handler == 'unisip':
+ server = classPing.Ping('132.230.252.228')
+ self.serverStatus = server.ping(3)
+ self.destNumber = '076120397897'
+
+ if self.handler == 'RZ1':
+ self.destNumber = '000'
diff --git a/For Weekly Test/Old/23-07-2011/classClient.py b/For Weekly Test/Old/23-07-2011/classClient.py
new file mode 100644
index 0000000..071fb35
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classClient.py
@@ -0,0 +1,122 @@
+import socket
+import sys
+import os
+import string
+import signal
+
+class TimeoutException(Exception):
+ pass
+
+class Connection:
+ def __init__(self, h, p):
+ self.host = h
+ self.port = p
+ self.s = None
+ self.connected = 0
+ self.debugMode = 0
+
+ def connect(self):
+ self.s = None
+
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM):
+ af, socktype, proto, canonname, sa = res
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ continue
+ try:
+ self.s.connect(sa)
+ except socket.error, msg:
+ self.s.close()
+ self.connected = 0
+ self.s = None
+ continue
+ break
+ if self.s is None:
+ self.connected = 0
+ return 0 #couldn't connect to the server
+ else:
+ self.connected = 1
+ return 1 #successfully connected to the server
+
+ def sendData(self, data):
+ if self.connected == 1:
+ try:
+ self.s.send(data)
+ return 1
+ except Exception, e:
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ return 2
+
+ else:
+ return 0
+
+ def receiveData(self, timeout):
+ if self.connected == 1:
+
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(timeout) #start the timeout alarm, for timeout seconds
+ try:
+ data = self.s.recv(1024)
+
+ #stop the timeout function
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ return data
+
+
+ except TimeoutException:
+ #timeout happened
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'TIMEOUT'
+
+ except Exception, e:
+
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ if error[0:11] == '[Errno 104]':
+ return 3 #the other side reset the connection,[Errno 104] Connection reset by peer
+
+ return 2
+ else:
+ return 0
+
+ def closeConnection(self):
+ if self.connected == 1:
+ try:
+ self.connected = 0
+ SHUT_RDWR = 2
+ self.s.shutdown(SHUT_RDWR)
+ self.s.close()
+ return 1
+ except Exception, e:
+ self.connected = 0
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ if error[0:11] == '[Errno 107]':
+ return 3 #the other side closed the connection before us, [Errno 107] Transport endpoint is not connected
+ return 2
+ else:
+ return 0
diff --git a/For Weekly Test/Old/23-07-2011/classClient.pyc b/For Weekly Test/Old/23-07-2011/classClient.pyc
new file mode 100644
index 0000000..fdecef6
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classClient.pyc
Binary files differ
diff --git a/For Weekly Test/Old/23-07-2011/classController.log b/For Weekly Test/Old/23-07-2011/classController.log
new file mode 100644
index 0000000..92f77e8
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classController.log
@@ -0,0 +1,91 @@
+
+
+------------------STARTED THE LOGGING 2011-07-22 01:00:29.543691 ------------------
+On: 2011-07-22 01:00:29.543733 Event: hai
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:50:53.070660 ------------------
+On: 2011-07-22 16:50:53.070749 Event: ====================== Preparing Test ======================
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:51:45.723586 ------------------
+On: 2011-07-22 16:51:45.723683 Event: ====================== Preparing Test ======================
+On: 2011-07-22 16:51:50.732078 Event: Connecting to Caller handler
+On: 2011-07-22 16:51:50.733557 Event: 605 General Handler Error: Origin handler no respond time out
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:54:19.549330 ------------------
+On: 2011-07-22 16:54:19.549421 Event: ====================== Preparing Test ======================
+On: 2011-07-22 16:54:24.557199 Event: Connecting to Caller handler
+On: 2011-07-22 16:54:24.559769 Event: Caller handler : Ready
+On: 2011-07-22 16:54:29.565037 Event: Connecting to Receiver handler
+On: 2011-07-22 16:54:29.568706 Event: Receiver handler : Ready
+On: 2011-07-22 16:54:29.568817 Event: ------------ Test Result ------------
+On: 2011-07-22 16:55:23.469295 Event: 1st Test, Origin :
+On: 2011-07-22 16:55:23.469387 Event: 1st Test, Destination :200
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:58:17.699985 ------------------
+On: 2011-07-22 16:58:17.700105 Event: ====================== Preparing Test ======================
+On: 2011-07-22 16:58:22.708382 Event: Connecting to Caller handler
+On: 2011-07-22 16:58:22.710843 Event: Caller handler : Ready
+On: 2011-07-22 16:58:27.718721 Event: Connecting to Receiver handler
+On: 2011-07-22 16:58:27.723527 Event: Receiver handler : Ready
+On: 2011-07-22 16:58:27.723649 Event: ------------ Test Result ------------
+On: 2011-07-22 16:58:59.345361 Event: 1st Test, Origin :
+On: 2011-07-22 16:58:59.345485 Event: 1st Test, Destination :200
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:06:37.921271 ------------------
+On: 2011-07-22 17:06:37.921359 Event: ====================== Preparing Test ======================
+On: 2011-07-22 17:06:42.925529 Event: Connecting to Caller handler
+On: 2011-07-22 17:06:42.927898 Event: Caller handler : Ready
+On: 2011-07-22 17:06:47.933596 Event: Connecting to Receiver handler
+On: 2011-07-22 17:06:47.937714 Event: Receiver handler : Ready
+On: 2011-07-22 17:06:47.937833 Event: ------------ Test Result ------------
+On: 2011-07-22 17:07:47.938087 Event: 1st Test, Origin :TIMEOUT
+On: 2011-07-22 17:07:47.938158 Event: 1st Test, Destination :200200
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:29:03.877972 ------------------
+On: 2011-07-22 17:29:03.878061 Event: ====================== Preparing Test ======================
+On: 2011-07-22 17:29:08.881561 Event: Connecting to Caller handler
+On: 2011-07-22 17:29:08.885637 Event: Caller handler : Ready
+On: 2011-07-22 17:29:13.889520 Event: Connecting to Receiver handler
+On: 2011-07-22 17:29:13.893404 Event: Receiver handler : Ready
+On: 2011-07-22 17:29:13.893555 Event: ------------ Test Result ------------
+On: 2011-07-22 17:29:51.517301 Event: 1st Test, Origin :
+On: 2011-07-22 17:29:51.517394 Event: 1st Test, Destination :200200
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:32:39.000234 ------------------
+On: 2011-07-22 17:32:39.000323 Event: ====================== Preparing Test ======================
+On: 2011-07-22 17:32:44.008084 Event: Connecting to Caller handler
+On: 2011-07-22 17:32:44.010775 Event: Caller handler : Ready
+On: 2011-07-22 17:32:49.017802 Event: Connecting to Receiver handler
+On: 2011-07-22 17:32:49.021564 Event: Receiver handler : Ready
+On: 2011-07-22 17:32:49.021677 Event: ------------ Test Result ------------
+On: 2011-07-22 17:33:49.022006 Event: 1st Test, Origin :TIMEOUT
+On: 2011-07-22 17:33:49.022088 Event: 1st Test, Destination :200200
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:35:07.158565 ------------------
+On: 2011-07-22 17:35:07.158654 Event: ====================== Preparing Test ======================
+On: 2011-07-22 17:35:12.166340 Event: Connecting to Caller handler
+On: 2011-07-22 17:35:12.168728 Event: Caller handler : Ready
+On: 2011-07-22 17:35:17.176657 Event: Connecting to Receiver handler
+On: 2011-07-22 17:35:17.182244 Event: Receiver handler : Ready
+On: 2011-07-22 17:35:17.182357 Event: ------------ Test Result ------------
+On: 2011-07-22 17:35:21.089364 Event: 1st Test, Origin :200
+On: 2011-07-22 17:35:21.089478 Event: 1st Test, Destination :200200
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:38:45.094846 ------------------
+On: 2011-07-22 17:38:45.094933 Event: ====================== Preparing Test ======================
+On: 2011-07-22 17:38:50.101576 Event: Connecting to Caller handler
+On: 2011-07-22 17:38:50.103882 Event: Caller handler : Ready
+On: 2011-07-22 17:38:55.110361 Event: Connecting to Receiver handler
+On: 2011-07-22 17:38:55.114445 Event: Receiver handler : Ready
+On: 2011-07-22 17:38:55.114566 Event: ------------ Test Result ------------
+On: 2011-07-22 17:39:00.453616 Event: 1st Test, Origin :200
+On: 2011-07-22 17:39:00.453693 Event: 1st Test, Destination :200
diff --git a/For Weekly Test/Old/23-07-2011/classController.py b/For Weekly Test/Old/23-07-2011/classController.py
new file mode 100644
index 0000000..a2c0b20
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classController.py
@@ -0,0 +1,154 @@
+import sys
+import os
+import subprocess
+
+import classClient
+import classDb
+import classPing
+
+import LogFileClass
+logger = LogFileClass.Logging('classController.log')
+
+from time import sleep
+
+
+class test:
+
+ def __init__(self, orig, dest, destNo):
+ self.orig = orig
+ self.dest = dest
+ self.destNo = destNo
+ self.repeatTest = None
+ self.portOrig = None
+ self.portDest = None
+ self.resultOrig = None
+ self.resultDest = None
+ self.testResult = None
+ self.caller = None
+ self.receiver = None
+ self.add = None
+
+ def FuncTest(self):
+
+ logger.logEvent('')
+
+ try:
+
+ if self.orig =="gsmBox1":
+ self.portOrig = 50095
+ self.add = ''
+
+ elif self.orig =="gsmBox2":
+ self.portOrig = 50096
+ self.add = ''
+
+ elif self.orig =="gsmBox3":
+ self.portOrig = 50097
+ self.add = ''
+
+ else:
+ self.portOrig = '50099'
+ self.add = 'localhost'
+ command="--command=python sipHandler.py " +self.portOrig
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(3)
+
+ caller = classClient.Connection(self.add,self.portOrig)
+
+ caller.connect()
+ message = self.orig+ '|-C'
+ caller.sendData(message)
+
+ origHandler = caller.receiveData(60)
+
+ if origHandler == "ready":
+ logger.logEvent('Caller handler : Ready')
+ try:
+
+ if self.dest =="gsmBox1":
+ self.portDest = 50102
+ self.add = ''
+
+ if self.dest =="gsmBox2":
+ self.portDest = 50103
+ self.add = ''
+
+ if self.dest =="gsmBox3":
+ self.portDest = 50103
+ self.add = ''
+
+ else:
+ self.portDest = '50100'
+ command="--command=python sipHandler.py " +self.portDest
+ subprocess.Popen(args=["gnome-terminal", command])
+
+ sleep(3)
+
+ receiver = classClient.Connection('localhost', self.portDest)
+
+ receiver.connect()
+ message = self.dest+ '|-R'
+ receiver.sendData(message)
+
+ destHandler = receiver.receiveData(0)
+
+ if destHandler == "ready":
+
+ caller.sendData("start|"+self.destNo)
+
+ self.resultOrig = caller.receiveData(60)
+ self.resultDest = receiver.receiveData(60)
+
+ logger.logEvent('1st Test, Origin :' +self.resultOrig)
+ logger.logEvent('1st Test, Destination :' +self.resultDest)
+
+
+ if self.resultOrig == 486 or self.resultDest == 486:
+
+ caller.sendData("start|"+self.destNo)
+
+ self.resultOrig = caller.receiveData(60)
+ self.resultDest = receiver.receiveData(60)
+
+ logger.logEvent('2nd Test, Origin :' +self.resultOrig)
+ logger.logEvent('2nd Test, Destination :' +self.resultDest)
+
+ if self.resultOrig == 486 or self.resultDest == 486:
+ self.testResult = 486
+ self.repeatTest = True
+
+ else:
+ self.testResult = 200
+
+ caller.sendData('487')
+ receiver.sendData('487')
+
+ else:
+
+ self.testResult = 200
+ caller.sendData('487')
+ receiver.sendData('487')
+
+ else:
+ self.testResult = 604
+ logger.logEvent('604 General Handler Error: Destination handler no respond timeout')
+ caller.sendData('487')
+
+ receiver.closeConnection()
+
+ except ValueError:
+ logger.logEvent('601 General Handler Error: Could not open Destination handler')
+ self.testResult = 601
+ caller.sendData('487')
+ caller.closeConnection()
+ else:
+ self.testResult = 605
+ logger.logEvent('605 General Handler Error: Origin handler no respond timeout')
+
+ caller.closeConnection()
+
+ except ValueError:
+ self.testResult = 602
+ logger.logEvent('602 General Handler Error: Could not open Origin handler')
+
diff --git a/For Weekly Test/Old/23-07-2011/classController.pyc b/For Weekly Test/Old/23-07-2011/classController.pyc
new file mode 100644
index 0000000..45f1e90
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classController.pyc
Binary files differ
diff --git a/For Weekly Test/Old/23-07-2011/classDB.py b/For Weekly Test/Old/23-07-2011/classDB.py
new file mode 100644
index 0000000..11a109f
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classDB.py
@@ -0,0 +1,271 @@
+import MySQLdb
+import string
+
+class DBMySQLConnection:
+ def __init__(self, username, password, host, dbname):
+ #initialize at the start all the user parameters
+ self.usern = username
+ self.passw = password
+ self.host = host
+ self.db = dbname
+ self.connectionCreated = 0
+ self.tasksList = list()
+ global debugMode
+ debugMode = 0
+
+ def connectDB(self):
+ try:
+ #try the connection
+ self.datBaseConn=MySQLdb.connect(self.host,self.usern, self.passw,self.db)
+ self.datBaseConn.paramstyle = 'format'
+ self.cur = self.datBaseConn.cursor() #make the cursor, used for sending queries
+ self.connectionCreated = 1 #use it as an indicator that the connection was created
+ return 1
+
+ except MySQLdb.Error, e:
+ #if we have an error then try to catch it
+ error=str(e)
+ if error[1:5] == '1045':
+ #wrong username or password
+ return 0
+ elif error[1:5] == '2002':
+ #can't connect to mysql, mysql shutdown or wrong host
+ return 2
+ else:
+ if debugMode == 1:
+ print error
+ return 3
+
+ def closeDBConn(self):
+ #close the connection to the database here
+ if self.connectionCreated == 1:
+ try:
+ #close the cursor and then the connection to the DB
+ self.cur.close()
+ self.datBaseConn.close()
+ return 1
+ except MySQLdb.Error, e:
+ #in case of an error
+ if debugMode == 1:
+ error = str(e)
+ print error
+ return 3
+ else:
+ #I never really had a connection
+ return 0
+
+ def anyTasksToDo(self):
+ #see are there any jobs to be executed and make a list out of it
+ if self.connectionCreated == 1:
+ try:
+ self.cur.execute("SELECT * FROM TempTaskTable")
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+ for record in output:
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+ self.tasksList.append(columns)
+ return 1
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def cleanTasksList(self):
+ if self.connectionCreated == 1:
+ del self.tasksList[:]
+ return 1
+ else:
+ return 0
+
+ def removeTaskFromList(self, taskID):
+ #remove only one task from the task list
+ if self.connectionCreated == 1:
+ for index in range(len(self.tasksList)):
+ item = self.tasksList[index]
+ if item[0] == str(taskID):
+ #self.tasksList.remove(index)
+ #print 'found it'
+ del self.tasksList[index]
+ return 1 #deleted taskID
+
+ return 2 #didn't find that taskID
+ else:
+ return 0
+
+ def deviceAddress(self,deviceName):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("SELECT `deviceIP` FROM DeviceAddress where `deviceName`=%s", deviceName)
+ #self.cur.execute()
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+ deviceAddr = ''
+ for record in output:
+ columns = list()
+ for entry in record:
+ deviceAddr = str(entry)
+ return deviceAddr
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3 #some error happened
+ else:
+ return 0 #I am not connected
+
+ def updateTaskResult(self, taskID, status):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE TaskTable SET status=%i WHERE taskID=%i"%(int(status), int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #update successful
+ else:
+ return 4 #taskID doesn't exist
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def updatePingResult(self, taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE PingResultTable SET sipServer=%i, sipGate=%i, sipLoc=%i, gsmBox1=%i, gsmBox2=%i WHERE taskNo=%i"%(int(sipServer), int(sipGate), int(sipLoc), int(gsmBox1), int(gsmBox2), int(taskNo)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #ping table updated
+ else:
+ return 4 #the taskNo didn't exist
+
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def deleteTempTask(self, taskID):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("DELETE FROM TempTaskTable WHERE taskID=%i"%(int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+
+ if successful == 1:
+ return 1 #deleted it
+ else:
+ return 4 #that taskID didn't exist or something else
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+
+ else:
+ return 0
+
+ def addResult(self, taskID, result):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("INSERT INTO ResultTable(taskID, result) VALUES ('%i', '%i')"%(int(taskID), int(result)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 1:
+ return 1 #successfully added the result
+ else:
+ return 4 #hmmm
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1062':
+ return 2 #duplicate entry for the key
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+
+ def insertTaskIn2(self, fromDevice, toDevice, taskNo):
+ if self.connectionCreated == 1:
+ try:
+ #I used here a transaction since I want the mysql to execute a few commands and tell me was it successful rather than to execute some and there happens a mistake and one part is updated and the other isn't
+ newQuery = "START TRANSACTION; INSERT INTO `TaskTable` (`taskNo`, `from`, `to`, `status`) VALUES ('" + str(taskNo) + "', '" + str(fromDevice) + "', '" + str(toDevice) +"', '0'); SELECT @taskID := LAST_INSERT_ID(); INSERT INTO `TempTaskTable` (`taskID`, `taskNo`, `from`, `to`) VALUES (@taskID, '" + str(taskNo) + "', '" + str(fromDevice) + "', '"+ str(toDevice) + "'); COMMIT;"
+
+
+ successful = self.cur.execute(newQuery)
+ output = self.cur.fetchone()
+
+
+ #without closing the cursos we get a MySQL error, the mistake is an internal mistak of the MySQLdb python library
+ # self.cur.close()
+ # self.cur = self.datBaseConn.cursor()
+
+ while self.cur.nextset() is not None: pass
+
+ newQuery1 = 'SELECT taskID FROM `TempTaskTable` ORDER BY taskID DESC LIMIT 1';
+ successful1 = self.cur.execute(newQuery1)
+ record = self.cur.fetchone()
+
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+
+ columns.append(str(taskNo))
+ columns.append(str(fromDevice))
+ columns.append(str(toDevice))
+ self.tasksList.append(columns)
+
+ return 1
+
+ if debugMode == 1:
+ print output
+
+ except MySQLdb.Error, e:
+ error = str(e)
+ if debugMode == 1:
+ print str(e)
+ if error[1:5] == '1062':
+ return 2 #duplicate entry for the key
+ return 3
+ else:
+ return 0
+
+
+ def searchTaskList(self, fromDevice, toDevice):
+ if self.connectionCreated == 1:
+ for item in self.tasksList:
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item [3]
+ if callFrom == fromDevice and callTo == toDevice:
+ return 1 #that task was found
+ return 2 #that task wasn't found
+ else:
+ return 0
diff --git a/For Weekly Test/Old/23-07-2011/classDb.pyc b/For Weekly Test/Old/23-07-2011/classDb.pyc
new file mode 100644
index 0000000..8bf4d7c
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classDb.pyc
Binary files differ
diff --git a/For Weekly Test/Old/23-07-2011/classPing.py b/For Weekly Test/Old/23-07-2011/classPing.py
new file mode 100644
index 0000000..e13b32b
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classPing.py
@@ -0,0 +1,28 @@
+import subprocess
+import string
+
+class Ping:
+
+ def __init__(self, pingAddress):
+ self.pingAddress = pingAddress
+
+ def ping(self,numberTries):
+ tried = 1
+ while numberTries >= tried:
+ tried += 1
+ #the parameter c 1 means only one ping to be sent, parameter W 3 means how many seconds the time out should be, 3 seconds
+ ping_cmd = subprocess.Popen(['ping', self.pingAddress, '-c', '1', '-W', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ unknownHost = int(string.find(ping_cmd, 'unknown host'))
+
+
+ if pingAlive != -1:
+ break
+
+ if unknownHost != -1:
+ return 2 #unknown host
+ if pingAlive != -1:
+ return 1 #ping works fine
+ else:
+ return 0 #no ping response
diff --git a/For Weekly Test/Old/23-07-2011/classPing.pyc b/For Weekly Test/Old/23-07-2011/classPing.pyc
new file mode 100644
index 0000000..0694881
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classPing.pyc
Binary files differ
diff --git a/For Weekly Test/Old/23-07-2011/classServer.py b/For Weekly Test/Old/23-07-2011/classServer.py
new file mode 100644
index 0000000..93c2f8e
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classServer.py
@@ -0,0 +1,152 @@
+import socket
+import sys
+import os
+import string
+import signal
+
+class TimeoutException(Exception):
+ pass
+
+class ServerHandler:
+
+ def __init__(self,p):
+ self.port = p
+ self.host = None #symbolic name meaning all available interfaces
+ self.s = None
+ self.connected = 0
+ self.address = "127.0.0.1" #address of the main controller
+ self.onceConnected = 0
+ self.error = 'No error'
+
+ self.debugMode = 0
+
+ def openSocket(self):
+ self.error = 'No error'
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC,
+ socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
+ af, socktype, proto, canonname, sa = res
+
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+
+ try:
+ self.s.bind(sa)
+ self.s.listen(1)
+ except socket.error, msg:
+ self.s.close()
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+ break
+
+ if self.s is None:
+ self.connected = 0
+ return 0
+ else: #accept the connection
+ self.connection, self.address = self.s.accept()
+ self.connected = 1
+ self.onceConnected = 1
+ return 1
+
+ def connectedTo(self):
+ return self.address
+
+ def receiveData(self, timeout):
+ if self.connected == 1:
+
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+
+ try:
+
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(timeout) #start the timeout alarm, for timeout seconds
+
+ data = self.connection.recv(1024)
+
+ #stop the timeout function
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ if not data:
+ self.connected = 0
+ return 'NO DATA'
+ else:
+ return data
+
+ except TimeoutException:
+ #timeout happened
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'TIMEOUT'
+
+ except Exception, e:
+ #stop the timeout timer
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ if error[0:11] == '[Errno 104]':
+ return 3 #the other side reset the connection,[Errno 104] Connection reset by peer
+
+ return 2
+ else:
+ return 0
+
+ def sendData(self, data):
+ if self.connected == 1:
+ try:
+ self.connection.send(data)
+ return 1
+
+ except Exception, e:
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connecected = 0
+ return 2
+ else:
+ return 0
+
+ def closeConnection(self):
+ if self.onceConnected == 1:
+ try:
+ self.connected = 0
+ SHUT_RDWR = 2
+ self.connection.shutdown(SHUT_RDWR)
+ self.connection.close()
+ return 1
+ except Exception, e:
+ self.connected = 0
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ if error[0:11] == '[Errno 107]':
+ return 3 #the other side closed the connection before us [Errno 107] Transport endpoint is not connected
+ return 2
+ else:
+ return 0
+
+ def killPort(self):
+ killResult = os.popen('lsof -i tcp:' + str(self.port) + ' | grep "python " | awk -F" " ' + "'{print $2}'").read()
+ killResult = killResult.replace('\n','')
+ print killResult
+ if killResult!='':
+ print killResult
+ killPort = os.popen("kill -9 " + killResult).read()
+ return 1
+ return 0
diff --git a/For Weekly Test/Old/23-07-2011/classServer.pyc b/For Weekly Test/Old/23-07-2011/classServer.pyc
new file mode 100644
index 0000000..fb0a0b1
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/classServer.pyc
Binary files differ
diff --git a/For Weekly Test/Old/23-07-2011/sipHandler.log b/For Weekly Test/Old/23-07-2011/sipHandler.log
new file mode 100644
index 0000000..318b896
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/sipHandler.log
@@ -0,0 +1,252 @@
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:52:46.741408 ------------------
+On: 2011-07-22 16:52:46.750880 Event: Connect to Controller
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:53:07.634838 ------------------
+On: 2011-07-22 16:53:07.643940 Event: Connect to Controller
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:53:29.942303 ------------------
+On: 2011-07-22 16:53:29.951637 Event: Connect to Controller
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:54:24.736302 ------------------
+On: 2011-07-22 16:54:24.747353 Event: Connect to Controller
+On: 2011-07-22 16:54:29.566373 Event: Beeing Landline
+On: 2011-07-22 16:54:29.566500 Event: Register Account to SIP server
+On: 2011-07-22 16:54:29.568543 Event: 100
+On: 2011-07-22 16:54:29.568647 Event: Receiver Handler Ready
+On: 2011-07-22 16:54:32.398823 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-22 16:54:32.900161 Event: Answer call
+On: 2011-07-22 16:54:33.400907 Event: Hangup call
+On: 2011-07-22 16:54:33.401550 Event: 200
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:54:19.715355 ------------------
+On: 2011-07-22 16:54:19.725015 Event: Connect to Controller
+On: 2011-07-22 16:54:24.558866 Event: Beeing SIP
+On: 2011-07-22 16:54:24.559005 Event: Register Account to SIP server
+On: 2011-07-22 16:54:24.559561 Event: 100
+On: 2011-07-22 16:54:24.559651 Event: Caller Handler Ready
+On: 2011-07-22 16:54:29.568876 Event: start
+On: 2011-07-22 16:54:29.568935 Event: Make a call to: 076145875681
+On: 2011-07-22 16:54:33.537284 Event: Call Connecting
+On: 2011-07-22 16:54:34.538569 Event: will Hangup call
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:58:17.878730 ------------------
+On: 2011-07-22 16:58:17.888488 Event: Connect to Controller
+On: 2011-07-22 16:58:22.710042 Event: Beeing SIP
+On: 2011-07-22 16:58:22.710168 Event: Register Account to SIP server
+On: 2011-07-22 16:58:22.710700 Event: 100
+On: 2011-07-22 16:58:22.710790 Event: Caller Handler Ready
+On: 2011-07-22 16:58:27.723708 Event: start
+On: 2011-07-22 16:58:27.723769 Event: Make a call to: 076145875681
+On: 2011-07-22 16:58:32.257841 Event: Call Connecting
+On: 2011-07-22 16:58:33.259153 Event: will Hangup call
+
+
+------------------STARTED THE LOGGING 2011-07-22 16:58:22.869026 ------------------
+On: 2011-07-22 16:58:22.879525 Event: Connect to Controller
+On: 2011-07-22 16:58:27.720122 Event: Beeing Landline
+On: 2011-07-22 16:58:27.720253 Event: Register Account to SIP server
+On: 2011-07-22 16:58:27.723308 Event: 100
+On: 2011-07-22 16:58:27.723441 Event: Receiver Handler Ready
+On: 2011-07-22 16:58:30.992886 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-22 16:58:31.494243 Event: Answer call
+On: 2011-07-22 16:58:31.994951 Event: Hangup call
+On: 2011-07-22 16:58:31.995415 Event: 200
+On: 2011-07-22 16:58:59.346231 Event: Terminate
+On: 2011-07-22 16:58:59.346456 Event: Close Connection to the Controller
+On: 2011-07-22 16:58:59.346575 Event: Close Connection to the Controller
+On: 2011-07-22 16:58:59.346618 Event: Goodbye
+On: 2011-07-22 16:58:59.348142 Event: Un-Rigester SIP Account
+On: 2011-07-22 16:59:00.504105 Event: Close Connection to the Controller
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:06:38.095955 ------------------
+On: 2011-07-22 17:06:38.106994 Event: Connect to Controller
+On: 2011-07-22 17:06:42.927084 Event: Beeing SIP
+On: 2011-07-22 17:06:42.927215 Event: Register Account to SIP server
+On: 2011-07-22 17:06:42.927755 Event: 100
+On: 2011-07-22 17:06:42.927845 Event: Caller Handler Ready
+On: 2011-07-22 17:06:47.937891 Event: start
+On: 2011-07-22 17:06:47.937954 Event: Make a call to: 076145875681
+On: 2011-07-22 17:06:52.369217 Event: Call Connecting
+On: 2011-07-22 17:06:53.370552 Event: will Hangup call
+On: 2011-07-22 17:07:47.938343 Event: Terminate
+On: 2011-07-22 17:07:47.938552 Event: Close Connection to the Controller
+On: 2011-07-22 17:07:47.938671 Event: Close Connection to the Controller
+On: 2011-07-22 17:07:47.938716 Event: Goodbye
+On: 2011-07-22 17:07:47.939081 Event: Un-Rigester SIP Account
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:06:43.091436 ------------------
+On: 2011-07-22 17:06:43.103178 Event: Connect to Controller
+On: 2011-07-22 17:06:47.934938 Event: Beeing Landline
+On: 2011-07-22 17:06:47.935069 Event: Register Account to SIP server
+On: 2011-07-22 17:06:47.937547 Event: 100
+On: 2011-07-22 17:06:47.937650 Event: Receiver Handler Ready
+On: 2011-07-22 17:06:51.164867 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-22 17:06:51.666299 Event: Call Connecting
+On: 2011-07-22 17:06:52.667580 Event: will Hangup call
+On: 2011-07-22 17:06:52.667926 Event: 200
+On: 2011-07-22 17:06:52.668166 Event: Answer call
+On: 2011-07-22 17:06:53.168820 Event: Hangup call
+On: 2011-07-22 17:06:53.169236 Event: 200
+On: 2011-07-22 17:06:53.670710 Event: Call Disconnected
+On: 2011-07-22 17:07:47.938815 Event: Terminate
+On: 2011-07-22 17:07:47.939018 Event: Close Connection to the Controller
+On: 2011-07-22 17:07:47.939134 Event: Close Connection to the Controller
+On: 2011-07-22 17:07:47.939177 Event: Goodbye
+On: 2011-07-22 17:07:47.940671 Event: Un-Rigester SIP Account
+On: 2011-07-22 17:07:49.185234 Event: Close Connection to the Controller
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:29:04.046061 ------------------
+On: 2011-07-22 17:29:04.056097 Event: Connect to Controller
+On: 2011-07-22 17:29:08.883163 Event: Beeing SIP
+On: 2011-07-22 17:29:08.884688 Event: Register Account to SIP server
+On: 2011-07-22 17:29:08.885322 Event: 100
+On: 2011-07-22 17:29:08.885484 Event: Caller Handler Ready
+On: 2011-07-22 17:29:13.893670 Event: start
+On: 2011-07-22 17:29:13.893736 Event: Make a call to: 076145875681
+On: 2011-07-22 17:29:18.580130 Event: Call Connecting
+On: 2011-07-22 17:29:19.581507 Event: will Hangup call
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:29:09.047015 ------------------
+On: 2011-07-22 17:29:09.056705 Event: Connect to Controller
+On: 2011-07-22 17:29:13.890830 Event: Beeing Landline
+On: 2011-07-22 17:29:13.890962 Event: Register Account to SIP server
+On: 2011-07-22 17:29:13.893230 Event: 100
+On: 2011-07-22 17:29:13.893338 Event: Receiver Handler Ready
+On: 2011-07-22 17:29:17.529191 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-22 17:29:18.030713 Event: Call Connecting
+On: 2011-07-22 17:29:19.031358 Event: will Hangup call
+On: 2011-07-22 17:29:19.031698 Event: 200
+On: 2011-07-22 17:29:19.031955 Event: Answer call
+On: 2011-07-22 17:29:19.532630 Event: Hangup call
+On: 2011-07-22 17:29:19.533078 Event: 200
+On: 2011-07-22 17:29:20.034557 Event: Call Disconnected
+On: 2011-07-22 17:29:51.517702 Event: Terminate
+On: 2011-07-22 17:29:51.517931 Event: Close Connection to the Controller
+On: 2011-07-22 17:29:51.518031 Event: Close Connection to the Controller
+On: 2011-07-22 17:29:51.518060 Event: Goodbye
+On: 2011-07-22 17:29:51.519713 Event: Un-Rigester SIP Account
+On: 2011-07-22 17:29:53.063721 Event: Close Connection to the Controller
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:32:39.174534 ------------------
+On: 2011-07-22 17:32:39.184258 Event: Connect to Controller
+On: 2011-07-22 17:32:44.009710 Event: Beeing SIP
+On: 2011-07-22 17:32:44.009850 Event: Register Account to SIP server
+On: 2011-07-22 17:32:44.010540 Event: 100
+On: 2011-07-22 17:32:44.011076 Event: Caller Handler Ready
+On: 2011-07-22 17:32:49.021797 Event: start
+On: 2011-07-22 17:32:49.021864 Event: Make a call to: 076145875681
+On: 2011-07-22 17:32:53.657049 Event: Call Connecting
+On: 2011-07-22 17:32:54.658385 Event: will Hangup call
+On: 2011-07-22 17:33:49.022348 Event: Terminate
+On: 2011-07-22 17:33:49.022544 Event: Close Connection to the Controller
+On: 2011-07-22 17:33:49.022640 Event: Close Connection to the Controller
+On: 2011-07-22 17:33:49.022667 Event: Goodbye
+On: 2011-07-22 17:33:49.022935 Event: Un-Rigester SIP Account
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:32:44.186998 ------------------
+On: 2011-07-22 17:32:44.200417 Event: Connect to Controller
+On: 2011-07-22 17:32:49.019093 Event: Beeing Landline
+On: 2011-07-22 17:32:49.019258 Event: Register Account to SIP server
+On: 2011-07-22 17:32:49.021346 Event: 100
+On: 2011-07-22 17:32:49.021484 Event: Receiver Handler Ready
+On: 2011-07-22 17:32:52.313985 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-22 17:32:52.815430 Event: Call Connecting
+On: 2011-07-22 17:32:53.816740 Event: will Hangup call
+On: 2011-07-22 17:32:53.817069 Event: 200
+On: 2011-07-22 17:32:53.817324 Event: Answer call
+On: 2011-07-22 17:32:54.318010 Event: Hangup call
+On: 2011-07-22 17:32:54.318457 Event: 200
+On: 2011-07-22 17:32:54.819907 Event: Call Disconnected
+On: 2011-07-22 17:33:49.022310 Event: Terminate
+On: 2011-07-22 17:33:49.022535 Event: Close Connection to the Controller
+On: 2011-07-22 17:33:49.022655 Event: Close Connection to the Controller
+On: 2011-07-22 17:33:49.022699 Event: Goodbye
+On: 2011-07-22 17:33:49.024497 Event: Un-Rigester SIP Account
+On: 2011-07-22 17:33:50.347230 Event: Close Connection to the Controller
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:35:12.327686 ------------------
+On: 2011-07-22 17:35:12.337419 Event: Connect to Controller
+On: 2011-07-22 17:35:17.178021 Event: Beeing Landline
+On: 2011-07-22 17:35:17.178144 Event: Register Account to SIP server
+On: 2011-07-22 17:35:17.182070 Event: 100
+On: 2011-07-22 17:35:17.182175 Event: Receiver Handler Ready
+On: 2011-07-22 17:35:20.038642 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-22 17:35:20.540080 Event: Call Connecting
+On: 2011-07-22 17:35:20.540149 Event: 200
+On: 2011-07-22 17:35:20.540357 Event: Answer call
+On: 2011-07-22 17:35:21.041033 Event: Hangup call
+On: 2011-07-22 17:35:21.041566 Event: 200
+On: 2011-07-22 17:35:21.089700 Event: Terminate
+On: 2011-07-22 17:35:21.089941 Event: Close Connection to the Controller
+On: 2011-07-22 17:35:21.090069 Event: Close Connection to the Controller
+On: 2011-07-22 17:35:21.090115 Event: Goodbye
+On: 2011-07-22 17:35:21.091949 Event: Un-Rigester SIP Account
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:35:07.327280 ------------------
+On: 2011-07-22 17:35:07.337311 Event: Connect to Controller
+On: 2011-07-22 17:35:12.167908 Event: Beeing SIP
+On: 2011-07-22 17:35:12.168030 Event: Register Account to SIP server
+On: 2011-07-22 17:35:12.168583 Event: 100
+On: 2011-07-22 17:35:12.168673 Event: Caller Handler Ready
+On: 2011-07-22 17:35:17.182418 Event: start
+On: 2011-07-22 17:35:17.182483 Event: Make a call to: 076145875681
+On: 2011-07-22 17:35:21.089055 Event: Call Connecting
+On: 2011-07-22 17:35:21.089125 Event: 200
+On: 2011-07-22 17:35:21.090233 Event: Terminate
+On: 2011-07-22 17:35:21.090403 Event: Close Connection to the Controller
+On: 2011-07-22 17:35:21.090491 Event: Close Connection to the Controller
+On: 2011-07-22 17:35:21.090518 Event: Goodbye
+On: 2011-07-22 17:35:21.090740 Event: Un-Rigester SIP Account
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:38:45.251738 ------------------
+On: 2011-07-22 17:38:45.261621 Event: Connect to Controller
+On: 2011-07-22 17:38:50.103095 Event: Beeing SIP
+On: 2011-07-22 17:38:50.103214 Event: Register Account to SIP server
+On: 2011-07-22 17:38:50.103741 Event: 100
+On: 2011-07-22 17:38:50.103828 Event: Caller Handler Ready
+On: 2011-07-22 17:38:55.115721 Event: start
+On: 2011-07-22 17:38:55.115787 Event: Make a call to: 076145875681
+On: 2011-07-22 17:39:00.453241 Event: Call Connecting
+On: 2011-07-22 17:39:00.453310 Event: 200
+On: 2011-07-22 17:39:00.454426 Event: Terminate
+On: 2011-07-22 17:39:00.454600 Event: Close Connection to the Controller
+On: 2011-07-22 17:39:00.454689 Event: Close Connection to the Controller
+On: 2011-07-22 17:39:00.454717 Event: Goodbye
+On: 2011-07-22 17:39:00.454938 Event: Un-Rigester SIP Account
+
+
+------------------STARTED THE LOGGING 2011-07-22 17:38:50.277006 ------------------
+On: 2011-07-22 17:38:50.289562 Event: Connect to Controller
+On: 2011-07-22 17:38:55.111613 Event: Beeing Landline
+On: 2011-07-22 17:38:55.111764 Event: Register Account to SIP server
+On: 2011-07-22 17:38:55.114271 Event: 100
+On: 2011-07-22 17:38:55.114391 Event: Receiver Handler Ready
+On: 2011-07-22 17:38:58.811983 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-22 17:38:59.313370 Event: Call Connecting
+On: 2011-07-22 17:38:59.313477 Event: 200
+On: 2011-07-22 17:38:59.313695 Event: Answer call
+On: 2011-07-22 17:38:59.814371 Event: Hangup call
+On: 2011-07-22 17:38:59.814754 Event: 200
+On: 2011-07-22 17:38:59.865862 Event: Call Disconnected
+On: 2011-07-22 17:39:00.453913 Event: Terminate
+On: 2011-07-22 17:39:00.454135 Event: Close Connection to the Controller
+On: 2011-07-22 17:39:00.454259 Event: Close Connection to the Controller
+On: 2011-07-22 17:39:00.454308 Event: Goodbye
+On: 2011-07-22 17:39:00.455577 Event: Un-Rigester SIP Account
+On: 2011-07-22 17:39:01.819806 Event: Close Connection to the Controller
diff --git a/For Weekly Test/Old/23-07-2011/sipHandler.py b/For Weekly Test/Old/23-07-2011/sipHandler.py
new file mode 100644
index 0000000..619efe3
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/sipHandler.py
@@ -0,0 +1,189 @@
+import sys
+import string
+import pjsua as pj
+import classServer
+import LogFileClass
+
+from time import sleep
+
+def log_cb(level, str, len):
+ print "--------starting Handler--------"
+
+# Receive events from incoming Call
+class Account(pj.AccountCallback):
+
+ def on_incoming_call(self, call):
+ global current_call
+
+ current_call = call
+ call_cb = Calling(current_call)
+ current_call.set_callback(call_cb)
+
+ logger.logEvent(current_call)
+ sleep(0.5)
+
+ call.answer(200)
+ logger.logEvent("Answer call")
+ sleep(0.5)
+
+ if current_call <> None:
+ logger.logEvent("Hangup call")
+ call.hangup()
+
+ logger.logEvent('200')
+
+class Calling(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+ def on_state(self):
+ global current_call
+
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ if self.call.info().state_text == "CONNECTING":
+ logger.logEvent("Call Connecting")
+ logger.logEvent('200')
+ server.sendData('200')
+
+ if self.call.info().last_reason == "Busy Here":
+ logger.logEvent('Number busy or Offline')
+ server.sendData('486')
+ logger.logEvent('486')
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ logger.logEvent('Call Disconnected')
+ current_call = None
+
+
+def make_call(uri):
+
+ try:
+
+ cb=Calling()
+ return acc.make_call(uri, cb)
+
+ except pj.Error, e:
+ print "408 " + str(e)
+ logger.logEvent('408')
+ return None
+
+global acc_cfg
+global handler
+global state
+port = sys.argv[1]
+
+lib = pj.Lib()
+stop = False
+
+logger = LogFileClass.Logging('sipHandler.log')
+logger.logEvent('')
+
+while stop <> True:
+
+ acc_cfg = None
+
+ lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+ server = classServer.ServerHandler(port)
+ logger.logEvent('Connect to Controller')
+ conn = server.openSocket()
+
+ message = server.receiveData(30)
+ handler = message[0:2]
+ state = message[3:5] # Receiver / caller
+
+ if handler == "-S":
+ logger.logEvent('Beeing SIP')
+ acc_cfg = pj.AccountConfig("132.230.4.8","mpselftest1","1mpselftest")
+
+ elif handler == "-L":
+ logger.logEvent('Beeing Landline')
+ acc_cfg = pj.AccountConfig("sipgate.de","1289459","MMW9AX")
+
+ elif handler == "-U":
+ logger.logEvent('Beeing University SIP')
+ acc_cfg = pj.AccountConfig("132.230.252.228", "4976120397897", "hB8M3WyFt61C")
+
+ else:
+ logger.logEvent('Unknown Message')
+ server.sendData('Unknown Message')
+ server.closeConnection()
+ sys.exit(1)
+
+ try:
+
+ logger.logEvent('Register Account to SIP server')
+ acc = lib.create_account(acc_cfg, cb=Account())
+
+
+ if acc.info().reg_status < 700:
+
+ if state == "-R":
+ logger.logEvent(acc.info().reg_status)
+ server.sendData('ready')
+ logger.logEvent('Receiver Handler Ready')
+
+ while 1:
+
+ data = server.receiveData(3)
+
+ if data == "487":
+ logger.logEvent('Terminate')
+ stop = True
+ break
+
+ elif state == "-C":
+ logger.logEvent(acc.info().reg_status)
+ server.sendData('ready')
+ logger.logEvent('Caller Handler Ready')
+
+ while 1:
+
+ data = server.receiveData(3)
+ event = data[0:5]
+ num = data[6:]
+
+ if event == "start" and num <> "":
+
+ logger.logEvent(event)
+ logger.logEvent('Make a call to: ' + num)
+ number = "sip:"+num+"@132.230.4.8"
+ make_call(number)
+
+ if data == "487":
+ stop = True
+ logger.logEvent('Terminate')
+ break
+
+ else:
+ logger.logEvent('Unknow Message')
+ server.sendData('Unknow Message')
+ server.closeConnection()
+ sys.exit(1)
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+
+ else:
+ logger.logEvent("488 Not Acceptable Here")
+ lib.destroy()
+
+
+ server.closeConnection()
+ logger.logEvent('Close Connection to the Controller')
+ except ValueError:
+ print "401 Unauthorized " + str(e)
+ logger.logEvent("401 Unauthorized ")
+
+logger.logEvent("Goodbye")
+acc.delete()
+lib.destroy()
+server.closeConnection()
+lib = None
+acc = None
+
diff --git a/For Weekly Test/Old/23-07-2011/test.py b/For Weekly Test/Old/23-07-2011/test.py
new file mode 100644
index 0000000..fee71b0
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/test.py
@@ -0,0 +1,8 @@
+import LogFileClass
+tri = 'cc'
+logger = LogFileClass.Logging('testing'+tri+'.log')
+logger.logEvent('')
+
+message = 'hai'
+
+logger.logEvent('opo iki' +message)
diff --git a/For Weekly Test/Old/23-07-2011/test1.py b/For Weekly Test/Old/23-07-2011/test1.py
new file mode 100644
index 0000000..e04e093
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/test1.py
@@ -0,0 +1,7 @@
+import sys
+import os
+
+mode = "-S"
+state = "-R"
+command="--command=python test.py" +mode +state
+subprocess.Popen(args=["gnome-terminal", command])
diff --git a/For Weekly Test/Old/23-07-2011/testing.log b/For Weekly Test/Old/23-07-2011/testing.log
new file mode 100644
index 0000000..75a361e
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/testing.log
@@ -0,0 +1,8 @@
+
+
+------------------STARTED THE LOGGING 2011-07-22 01:01:19.482585 ------------------
+On: 2011-07-22 01:01:19.482630 Event: opo ikihai
+
+
+------------------STARTED THE LOGGING 2011-07-22 01:01:52.806697 ------------------
+On: 2011-07-22 01:01:52.806739 Event: opo ikihai
diff --git a/For Weekly Test/Old/23-07-2011/testingcc.log b/For Weekly Test/Old/23-07-2011/testingcc.log
new file mode 100644
index 0000000..5f42730
--- /dev/null
+++ b/For Weekly Test/Old/23-07-2011/testingcc.log
@@ -0,0 +1,4 @@
+
+
+------------------STARTED THE LOGGING 2011-07-22 01:20:51.929961 ------------------
+On: 2011-07-22 01:20:51.930005 Event: opo ikihai
diff --git a/For Weekly Test/Old/30-07-2011/ClientClass.py b/For Weekly Test/Old/30-07-2011/ClientClass.py
new file mode 100644
index 0000000..46c3b00
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/ClientClass.py
@@ -0,0 +1,123 @@
+import socket
+import sys
+import os
+import string
+import signal
+
+class TimeoutException(Exception):
+ pass
+
+class Connection:
+ def __init__(self, h, p):
+ self.host = h
+ self.port = p
+ self.s = None
+ self.connected = 0
+
+ self.debugMode = 0
+
+ def connect(self):
+ self.s = None
+
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM):
+ af, socktype, proto, canonname, sa = res
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ continue
+ try:
+ self.s.connect(sa)
+ except socket.error, msg:
+ self.s.close()
+ self.connected = 0
+ self.s = None
+ continue
+ break
+ if self.s is None:
+ self.connected = 0
+ return 0 #couldn't connect to the server
+ else:
+ self.connected = 1
+ return 1 #successfully connected to the server
+
+ def sendData(self, data):
+ if self.connected == 1:
+ try:
+ self.s.send(data)
+ return 1
+ except Exception, e:
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ return 2
+
+ else:
+ return 0
+
+ def receiveData(self, timeout):
+ if self.connected == 1:
+
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(timeout) #start the timeout alarm, for timeout seconds
+ try:
+ data = self.s.recv(1024)
+
+ #stop the timeout function
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ return data
+
+
+ except TimeoutException:
+ #timeout happened
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'TIMEOUT'
+
+ except Exception, e:
+
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ if error[0:11] == '[Errno 104]':
+ return 3 #the other side reset the connection,[Errno 104] Connection reset by peer
+
+ return 2
+ else:
+ return 0
+
+ def closeConnection(self):
+ if self.connected == 1:
+ try:
+ self.connected = 0
+ SHUT_RDWR = 2
+ self.s.shutdown(SHUT_RDWR)
+ self.s.close()
+ return 1
+ except Exception, e:
+ self.connected = 0
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ if error[0:11] == '[Errno 107]':
+ return 3 #the other side closed the connection before us, [Errno 107] Transport endpoint is not connected
+ return 2
+ else:
+ return 0
diff --git a/For Weekly Test/Old/30-07-2011/ClientClass.pyc b/For Weekly Test/Old/30-07-2011/ClientClass.pyc
new file mode 100644
index 0000000..7cdfa60
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/ClientClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/30-07-2011/Controller.py b/For Weekly Test/Old/30-07-2011/Controller.py
new file mode 100644
index 0000000..e4a4566
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/Controller.py
@@ -0,0 +1,98 @@
+import sys
+import ClientClass
+import DbClass
+import ControllerClass
+import PingClass
+from time import sleep
+
+
+def ping(handler):
+
+ global serverStatus
+
+ if handler == 'landline':
+ server = PingClass.Ping('sipgate.de')
+ serverStatus = server.ping(3)
+
+ elif handler == 'sip':
+ server = PingClass.Ping('132.230.4.8')
+ serverStatus = server.ping(3)
+
+ elif handler == 'unisip':
+ server = PingClass.Ping('132.230.252.228')
+ serverStatus = server.ping(3)
+
+ elif handler == 'gsmr1':
+ server = PingClass.Ping('localhost')
+ serverStatus = server.ping(3)
+
+ elif handler == 'gsmr2':
+ server = PingClass.Ping('132.230.4.64')
+ serverStatus = server.ping(3)
+
+
+db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
+db.connectDB()
+dbStatus = db.connectDB()
+
+if dbStatus == 1:
+
+ if db.anyTasksToDo() == 1:
+ i=0
+ for item in db.tasksList:
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item[3]
+
+ destination = db.deviceAddress(str(callTo))
+
+ caller = db.deviceAddress(str(callFrom))
+
+ callAdd = caller[0]
+ recAdd = destination[0]
+ destNo = destination[1]
+
+ if callFrom == 'unisip':
+ destNo = destNo[7:]
+
+
+ print '\n'
+ print "Task ID: ", taskID
+ print "Calling From: ", callFrom
+ print "To: ", callTo
+ print "number: ", destNo
+
+ ping(callFrom)
+
+ if serverStatus <> 0:
+
+ ping(callTo)
+ if serverStatus <> 0:
+
+ makeTest = ControllerClass.test(callFrom, callAdd, callTo, recAdd, destNo)
+ makeTest.FuncTest()
+
+ db.addResult(taskID, makeTest.testResult)
+
+ if makeTest.repeatTest == True:
+ db.insertTaskIn2(callTo,callFrom,taskNo)
+
+ print "Result :", makeTest.testResult
+
+ db.deleteTempTask(taskID)
+ db.tasksList.remove(item)
+ db.tasksList.insert(i,'')
+ i = i+1
+
+ sleep(3)
+ else:
+ print "[failed] 500 "+callTo+ " Server Internal Error"
+ else:
+ print "[failed] 500 "+callFrom+ " Server Internal Error"
+ db.cleanTasksList()
+ else:
+ print "No job at all"
+else:
+ sys.exit(5)
+
diff --git a/For Weekly Test/Old/30-07-2011/ControllerClass.py b/For Weekly Test/Old/30-07-2011/ControllerClass.py
new file mode 100644
index 0000000..9c6b74e
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/ControllerClass.py
@@ -0,0 +1,233 @@
+import sys
+import os
+import subprocess
+
+import ClientClass
+
+import LogFileClass
+logger = LogFileClass.Logging('TestProcessLog.log')
+
+from time import sleep
+
+
+class test:
+
+ def __init__(self, callFrom, callAdd, accCaller, callTo, recAdd, destNo, accDest):
+
+ self.callFrom = callFrom
+ self.dest = callTo
+ self.destNo = destNo
+ self.accDest = accDest
+ self.accCaller = accCaller
+ self.repeatTest = None
+ self.portAdd = None
+ self.portCaller = None
+ self.portDest = None
+ self.resultCaller = None
+ self.resultDest = None
+ self.testResult = None
+ self.callAdd = callAdd
+ self.recAdd = recAdd
+ self.receiver = None
+ self.caller = None
+ self.connected = None
+
+
+ def FuncTest(self):
+
+ logger.logEvent('')
+
+ self.initCaller()
+ sleep(3)
+
+ self.callerGreeting()
+
+ if self.connected == 'OK':
+
+ self.caller.sendData('CALLER|'+self.destNo)
+ callerHandler = self.caller.receiveData(15)
+
+ if callerHandler == "CALLER READY":
+ logger.logEvent('Caller handler : Ready')
+
+ self.initReceiver()
+ sleep(3)
+ self.receiverGreeting()
+
+ if self.connected == 'OK':
+
+ self.receiver.sendData('RECEIVER')
+ destHandler = self.receiver.receiveData(15)
+
+ if destHandler == 'RECEIVER READY':
+ logger.logEvent('Receiver handler : Ready')
+
+ self.startCall()
+ self.waitingFeedback()
+
+ else:
+ self.testResult = 604
+ logger.logEvent('604 General Handler Error: Destination handler no respond timeout')
+ self.caller.sendData('TERMINATE CONNECTION')
+ self.receiver.closeConnection()
+
+ else:
+ logger.logEvent('998 General Handler Error: Could not connect Destination handler')
+ self.testResult = 998
+ self.caller.sendData('TERMINATE CONNECTION')
+ self.caller.closeConnection()
+ else:
+ self.testResult = 605
+ logger.logEvent('605 General Handler Error: caller handler no respond timeout')
+
+ self.caller.closeConnection()
+
+ else:
+ self.testResult = 999
+ logger.logEvent('999 General Handler Error: Could not connect to Caller handler')
+
+
+
+ def waitingFeedback(self):
+ logger.logEvent('Waiting Feedback')
+ self.resultCaller = self.caller.receiveData(30)
+ self.resultDest = self.receiver.receiveData(30)
+
+ if self.resultCaller <> 'CALL OK' or self.resultDest <> 'CALL OK':
+
+ logger.logEvent('Test Failed')
+ self.testResult = 486
+ self.repeatTest = True
+ self.initTerminate()
+
+ else:
+ logger.logEvent('Test Succeed')
+ self.testResult = 200
+ self.initTerminate()
+
+
+ def startCall(self):
+ logger.logEvent('Start Call')
+ self.receiver.sendData('RECEIVE START')
+ self.caller.sendData('CALL START')
+
+
+ def initCaller(self):
+ logger.logEvent('init Caller')
+ logger.logEvent(self.callFrom)
+
+ if self.callFrom =="gsmr1":
+ self.portCaller = 50007
+ self.portAdd = ''
+ self.initGSM(self.portCaller, self.portAdd)
+
+ elif self.callFrom =="gsmr2":
+ self.portCaller = 50008
+
+ elif self.callFrom =="gsmr3":
+ self.portCaller = 50009
+
+ elif self.callFrom =="gsmeO":
+ self.portCaller = 50010
+ self.portAdd = '/dev/ttyUSB0'
+ self.initGSM(self.portCaller, self.portAdd)
+
+ elif self.callFrom =="gsmeV":
+ self.portCaller = 50011
+ self.portAdd = '/dev/ttyUSB1'
+ self.initGSM(self.portCaller, self.portAdd)
+
+ elif self.callFrom =="gsmeT":
+ self.portCaller = 50012
+ self.portAdd = ''
+ self.initGSM(self.portCaller, self.portAdd)
+
+ elif self.callFrom =="gsmeE":
+ self.portCaller = 50013
+ self.portAdd = '/dev/ttyUSB2'
+ self.initGSM(self.portCaller, self.portAdd)
+
+ else:
+ self.portCaller = 50099
+ subprocess.Popen(args=["gnome-terminal", '--command=python SIPHandler.py '+self.accCaller+ ' ' +str(self.portCaller)])
+
+ def initReceiver(self):
+ logger.logEvent('init Receiver')
+ logger.logEvent(self.dest)
+
+ if self.dest =="gsmr1":
+ self.portDest = 50007
+ self.portAdd = ''
+ self.initGSM(self.portDest, self.portAdd)
+
+ elif self.dest =="gsmr2":
+ self.portDest = 50008
+
+ elif self.dest =="gsmr3":
+ self.portDest = 50009
+
+ elif self.dest =="gsmeO":
+ self.portDest = 50010
+ self.portAdd = '/dev/ttyUSB0'
+ self.initGSM(self.portDest, self.portAdd)
+
+ elif self.dest =="gsmeV":
+ self.portDest = 50011
+ self.portAdd = '/dev/ttyUSB1'
+ self.initGSM(self.portDest, self.portAdd)
+
+ elif self.dest =="gsmeT":
+ self.portDest = 50012
+ self.portAdd = ''
+ self.initGSM(self.portDest, self.portAdd)
+
+ elif self.dest =="gsmeE":
+ self.portDest = 50013
+ self.portAdd = '/dev/ttyUSB2'
+ self.initGSM(self.portDest, self.portAdd)
+
+ else:
+ self.portDest = 50100
+ subprocess.Popen(args=['gnome-terminal', '--command=python SIPHandler.py '+self.accDest+ ' ' +str(self.portDest)])
+
+ def initTerminate(self):
+ self.caller.sendData('TERMINATE CONNECTION')
+ self.receiver.sendData('TERMINATE CONNECTION')
+
+ def callerGreeting(self):
+ self.connected = None
+ self.caller = ClientClass.Connection(self.callAdd,self.portCaller)
+ self.caller.connect()
+
+ if self.caller.connected == 1:
+ logger.logEvent('Connected to Caller Handler')
+ self.caller.sendData('HELLO HANDLER')
+ if self.caller.receiveData(15) == 'HELLO CONTROLLER':
+ logger.logEvent('Caller Handler respond')
+ self.connected = 'OK'
+ else:
+ logger.logEvent('Cannt connect to Caller')
+ self.connected = 'NOT OK'
+
+ def receiverGreeting(self):
+ self.connected = None
+ self.receiver = ClientClass.Connection(self.recAdd, self.portDest)
+ self.receiver.connect()
+
+ if self.receiver.connected == 1:
+ logger.logEvent('Connected to Receiver Handler')
+ self.receiver.sendData('HELLO HANDLER')
+ if self.receiver.receiveData(15) == 'HELLO CONTROLLER':
+ logger.logEvent('Receiver Handler respond')
+ self.connected = 'OK'
+ else:
+ logger.logEvent('Cannt connect to Receiver')
+ self.connected = 'NOT OK'
+
+ def initGSM(self, portCommunication, portDevice):
+
+ subprocess.Popen(args=["gnome-terminal", '--command=python GSMHandler.py '+str(portCommunication)+ ' ' +str(portDevice)])
+
+
+
+
diff --git a/For Weekly Test/Old/30-07-2011/ControllerClass.pyc b/For Weekly Test/Old/30-07-2011/ControllerClass.pyc
new file mode 100644
index 0000000..3efebe9
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/ControllerClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/30-07-2011/DbClass.py b/For Weekly Test/Old/30-07-2011/DbClass.py
new file mode 100644
index 0000000..e5ef961
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/DbClass.py
@@ -0,0 +1,295 @@
+import MySQLdb
+import string
+
+class DBMySQLConnection:
+ def __init__(self, username, password, host, dbname):
+ #initialize at the start all the user parameters
+ self.usern = username
+ self.passw = password
+ self.host = host
+ self.db = dbname
+ self.connectionCreated = 0
+ self.tasksList = list()
+ self.errCode = None
+ global debugMode
+ debugMode = 0
+
+ def connectDB(self):
+ try:
+ #try the connection
+ self.datBaseConn=MySQLdb.connect(self.host,self.usern, self.passw,self.db)
+ self.datBaseConn.paramstyle = 'format'
+ self.cur = self.datBaseConn.cursor() #make the cursor, used for sending queries
+ self.connectionCreated = 1 #use it as an indicator that the connection was created
+ return 1
+
+ except MySQLdb.Error, e:
+ #if we have an error then try to catch it
+ error=str(e)
+ if error[1:5] == '1045':
+ #wrong username or password
+ return 0
+ elif error[1:5] == '2002':
+ #can't connect to mysql, mysql shutdown or wrong host
+ return 2
+ else:
+ if debugMode == 1:
+ print error
+ return 3
+
+ def closeDBConn(self):
+ #close the connection to the database here
+ if self.connectionCreated == 1:
+ try:
+ #close the cursor and then the connection to the DB
+ self.cur.close()
+ self.datBaseConn.close()
+ return 1
+ except MySQLdb.Error, e:
+ #in case of an error
+ if debugMode == 1:
+ error = str(e)
+ print error
+ return 3
+ else:
+ #I never really had a connection
+ return 0
+
+ def anyTasksToDo(self):
+ #see are there any jobs to be executed and make a list out of it
+ if self.connectionCreated == 1:
+ try:
+ self.cur.execute("SELECT * FROM TempTaskTable")
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+
+ for record in output:
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+ #columns.append(str(0))
+ self.tasksList.append(columns)
+ return 1
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def cleanTasksList(self):
+ if self.connectionCreated == 1:
+ del self.tasksList[:]
+ return 1
+ else:
+ return 0
+
+ def removeTaskFromList(self, taskID):
+ #remove only one task from the task list
+ if self.connectionCreated == 1:
+ for index in range(len(self.tasksList)):
+ item = self.tasksList[index]
+ if item[0] == str(taskID):
+ #self.tasksList.remove(index)
+ #print 'found it'
+ del self.tasksList[index]
+ return 1 #deleted taskID
+
+ return 2 #didn't find that taskID
+ else:
+ return 0
+
+ def deviceAddress(self,deviceName):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("SELECT `deviceIP`,`number`, `username`, `password`, `server` FROM DeviceAddressTable where `deviceName`=%s", deviceName)
+ output = self.cur.fetchall() #get the mysql response
+ #parse the output from the mysql by creating a list
+ #with lists where each attribue(column) gets independent
+ #element of the list
+
+ deviceAddr = ''
+ for record in output:
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+ deviceAddr = columns
+
+ return deviceAddr
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3 #some error happened
+ else:
+ return 0 #I am not connected
+
+ def updateTaskResult(self, taskID, status):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE TaskTable SET status=%i WHERE taskID=%i"%(int(status), int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #update successful
+ else:
+ return 4 #taskID doesn't exist
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def updatePingResult(self, taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("UPDATE PingResultTable SET sipServer=%i, sipGate=%i, sipLoc=%i, gsmBox1=%i, gsmBox2=%i WHERE taskNo=%i"%(int(sipServer), int(sipGate), int(sipLoc), int(gsmBox1), int(gsmBox2), int(taskNo)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 0:
+ return 1 #ping table updated
+ else:
+ return 4 #the taskNo didn't exist
+
+
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+ def deleteTempTask(self, taskID):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("DELETE FROM TempTaskTable WHERE taskID=%i"%(int(taskID)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+
+ if successful == 1:
+ return 1 #deleted it
+ else:
+ return 4 #that taskID didn't exist or something else
+ except MySQLdb.Error, e:
+ if debugMode == 1:
+ print str(e)
+ return 3
+
+ else:
+ return 0
+
+ def addResult(self, taskID, result):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("INSERT INTO ResultTable(taskID, result) VALUES ('%i', '%i')"%(int(taskID), int(result)))
+ output = self.cur.fetchone()
+
+ if debugMode == 1:
+ print output
+ if successful == 1:
+ return 1 #successfully added the result
+ else:
+ return 4 #hmmm
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1062':
+ return 2 #duplicate entry for the key
+ if debugMode == 1:
+ print str(e)
+ return 3
+ else:
+ return 0
+
+
+ def insertTaskIn2(self, fromDevice, toDevice, taskNo, status):
+ if self.connectionCreated == 1:
+ try:
+ #I used here a transaction since I want the mysql to execute a few commands and tell me was it successful rather than to execute some and there happens a mistake and one part is updated and the other isn't
+ newQuery = "START TRANSACTION; INSERT INTO `TaskTable` (`taskNo`, `from`, `to`, `status`) VALUES ('" + str(taskNo) + "', '" + str(fromDevice) + "', '" + str(toDevice) +"', '0'); SELECT @taskID := LAST_INSERT_ID(); INSERT INTO `TempTaskTable` (`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES (@taskID, '" + str(taskNo) + "', '" + str(fromDevice) + "', '"+ str(toDevice) + "', '"+ str(status) + "'); COMMIT;"
+
+
+ successful = self.cur.execute(newQuery)
+ output = self.cur.fetchone()
+
+
+ #without closing the cursos we get a MySQL error, the mistake is an internal mistak of the MySQLdb python library
+ # self.cur.close()
+ # self.cur = self.datBaseConn.cursor()
+
+ while self.cur.nextset() is not None: pass
+
+ newQuery1 = 'SELECT taskID FROM `TempTaskTable` ORDER BY taskID DESC LIMIT 1';
+ successful1 = self.cur.execute(newQuery1)
+ record = self.cur.fetchone()
+
+ columns = list()
+ for entry in record:
+ columns.append(str(entry))
+
+ columns.append(str(taskNo))
+ columns.append(str(fromDevice))
+ columns.append(str(toDevice))
+ columns.append(str(status))
+ #columns.append(str(0))
+ self.tasksList.append(columns)
+
+ return 1
+
+ if debugMode == 1:
+ print output
+
+ except MySQLdb.Error, e:
+ error = str(e)
+ if debugMode == 1:
+ print str(e)
+ if error[1:5] == '1062':
+ return 2 #duplicate entry for the key
+ return 3
+ else:
+ return 0
+
+
+ def searchTaskList(self, fromDevice, toDevice):
+ if self.connectionCreated == 1:
+ for item in self.tasksList:
+ if item != '':
+ callFrom = item[2]
+ callTo = item [3]
+ if callFrom == fromDevice and callTo == toDevice:
+ return 1 #that task was found
+ return 2 #that task wasn't found
+ else:
+ return 0
+
+ def errorCode(self,code):
+ if self.connectionCreated == 1:
+ try:
+ successful = self.cur.execute("SELECT description FROM ErrorCodeTable where `errorcode`=%s", code)
+ data = self.cur.fetchone()
+ self.errCode = data[0]
+ return self.errCode
+
+ except MySQLdb.Error, e:
+ error = str(e)
+ if error[1:5] == '1146':
+ return 2 #the table doesn't exist
+ if debugMode == 1:
+ print str(e)
+ return 3 #some error happened
+ else:
+ return 0 #I am not connected
diff --git a/For Weekly Test/Old/30-07-2011/DbClass.pyc b/For Weekly Test/Old/30-07-2011/DbClass.pyc
new file mode 100644
index 0000000..bb6a774
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/DbClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/30-07-2011/GSMClass.py b/For Weekly Test/Old/30-07-2011/GSMClass.py
new file mode 100644
index 0000000..e994814
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/GSMClass.py
@@ -0,0 +1,304 @@
+from serial import * #serial port library
+import string
+import sys
+import signal
+
+class TimeoutException(Exception):
+ pass
+
+class serialPort():
+
+ def __init__(self, portAddress, baudRate, timeout):
+ self.portAddress = portAddress
+ self.portExist = 0
+ self.ser = 0
+ self.baudRate = baudRate
+ self.signalStrength = 0
+ #self.callerConnected = -1
+ self.timer = timeout
+
+ self.debugMode = 0
+
+ def portInit(self):
+ portName = self.portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ return 0
+ else:
+ try:
+ self.ser = Serial(
+ port=self.portAddress,
+ baudrate=self.baudRate,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE
+ #timeout=0,
+ #writeTimeout=0
+ #xonxoff=0,
+ #rtscts=0
+ #interCharTimeout=None
+ #I didn't need to set these variables :)
+ )
+
+ self.ser.flushInput() #clean the input buffer for serial port
+ self.ser.write('AT\r')
+
+ received = self.__receiveData()
+
+ if received == 'OK':
+ self.portExist = 1
+ return 1 #cellphone is OK, receives commands
+ elif received == 'TIMEOUT':
+ return 'TIMEOUT'
+ else:
+ return 2 #cellphone has an error
+
+ except Exception, e:
+ import traceback
+ if self.debugMode == 1:
+ print e
+ print traceback.format_exc()
+
+ self.portExist = 3
+ return 3
+
+ def callNumber(self,numberToCall):
+ if self.portExist == 1:
+ try:
+ self.ser.flushInput() #clean the input buffer for serial port
+ self.ser.write('ATD'+str(numberToCall)+';\r')
+ if self.__receiveData() == 'OK':
+ return 1
+ else:
+ return 4
+
+ except Exception, e:
+ import traceback
+ if self.debugMode == 1:
+ print e
+ print traceback.format_exc()
+
+ return 3
+ else:
+ return 0
+
+
+ def hangUp(self):
+ if self.portExist == 1:
+ try:
+ self.ser.flushInput() #clean the input buffer for serial port
+ self.ser.write('AT+CHUP\r')
+ received = self.__receiveData()
+ if received == 'OK':
+ return 1
+ elif received == 'ERROR':
+ return 2 #other side hang up the call
+ else:
+ return 4
+ except Exception, e:
+ import traceback
+ if self.debugMode == 1:
+ print e
+ print traceback.format_exc()
+ return 3
+ else:
+ return 0
+
+
+ def closePort(self):
+ if self.portExist == 1:
+ try:
+ self.ser.flushInput() #clean the input buffer for serial port
+ self.ser.close()
+ return 1
+ except Exception, e:
+ import traceback
+ if self.debugMode == 1:
+ print e
+ print traceback.format_exc()
+ return 3
+ else:
+ return 0
+
+ def getSignalQuality(self):
+ if self.portExist == 1:
+ try:
+ self.ser.flushInput() #clean the input buffer for serial port
+ self.ser.write('AT+CSQ\r')
+ if self.__receiveData() == 'OK':
+ if self.__receiveData == 'SIGNAL':
+ return 1
+ else:
+ return 4
+ else:
+ return 2
+ except Exception, e:
+ import traceback
+ if self.debugMode == 1:
+ print e
+ print traceback.format_exc()
+ return 3
+
+ else:
+ return 0
+
+ def receiveCall(self):
+ if self.portExist == 1:
+ try:
+ self.ser.flushInput() #clean the input buffer for serial port
+ if self.__receiveData() == 'RING':
+ self.ser.write('ATA\r')
+ if self.__receiveData()=='OK':
+ return 1
+ else:
+ return 4
+ else:
+ return 2
+
+ except Exception, e:
+ import traceback
+ if self.debugMode == 1:
+ print e
+ print traceback.format_exc()
+ return 3
+ else:
+ return 0
+
+ def currentCall(self):
+ if self.portExist == 1:
+ try:
+ self.ser.flushInput() #clean the input buffer for serial port
+ self.ser.write('AT+CLCC\r')
+ received = self.__receiveData()
+ if received == 'OK':
+ return 2 #not yet in a call
+ elif received == 'ACTIVE':
+ return 1 #in a call
+ elif received == 'HELD':
+ return 5 #held call
+ elif received == 'DIALING':
+ return 6 #dialing
+ elif received == 'ALERTING':
+ return 7 #alerting the call
+ elif received == 'INCOMING':
+ return 8 #incoming call
+ elif received == 'WAITING':
+ return 9 #waiting for a call
+
+ else:
+ return received #in some other state
+ except Exception, e:
+ import traceback
+ if self.debugMode == 1:
+ print e
+ print traceback.format_exc()
+ return 3
+ else:
+ return 0
+
+ def __receiveData(self):
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(self.timer)
+
+ bufferData = ''
+ lines = ''
+ line = ''
+
+ try:
+ while True:
+ bufferData = bufferData + self.ser.read(self.ser.inWaiting()) #read the serial port and add it to the buffer variable
+ if '\n' in bufferData: #if a new line character is found in the buffer then the cellphone has sent something
+ lines = bufferData.split('\n') #parse the buffer variable with the new line character
+ last_received = lines.pop(0) #put into last_received variable the first content from lines (FIFO)
+
+ bufferData = '\n'.join(lines) #add a new line to the buffer variable
+
+ last_received=last_received.split('\n') #parse the last received value with new lines
+ line = last_received[0].replace(chr(13), '') #remove \r from the first parsed value in last_received and return me a nicely parsed value :)
+ if self.debugMode == 1:
+ if len(line) > 0:
+ print line
+
+ if line == 'OK':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'OK'
+
+ elif line == 'ERROR':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'ERROR'
+
+ elif line[0:11] == '+CME ERROR:':
+ if self.debugMode == 1:
+ print 'ERROR:', line
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'ERROR'
+
+ elif line == 'RING':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'RING'
+
+ elif line[0:5] == '+CSQ:': #+CSQ:
+ space = int(string.find(line,' '))+1 #find the (space) sign
+ coma = int(string.find(line,',')) #find the , (coma) sign
+ self.signalStrength = (int(line[space:coma])*2)-113
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'SIGNAL'
+
+ elif line == 'NO CARRIER':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'NO CARRIER'
+
+ elif line == 'BUSY':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'BUSY'
+
+ elif line[0:6] == '+CLCC:':
+ #+CLCC: 1,0,
+ #self.ser.flushInput()
+ if line[11:12] == '0':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'ACTIVE'
+ elif line[11:12] == '1':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'HELD'
+ elif line[11:12] == '2':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'DIALING'
+ elif line[11:12] == '3':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'ALERTING'
+ elif line[11:12] == '4':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'INCOMING'
+ elif line[11:12] == '5':
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'WAITING'
+
+ except TimeoutException:
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'TIMEOUT'
+
+ except Exception, e:
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ print 'NO GOOD'
+ print e
+ return 3
diff --git a/For Weekly Test/Old/30-07-2011/GSMClass.pyc b/For Weekly Test/Old/30-07-2011/GSMClass.pyc
new file mode 100644
index 0000000..93ccd6c
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/GSMClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/30-07-2011/GSMHandler.py b/For Weekly Test/Old/30-07-2011/GSMHandler.py
new file mode 100644
index 0000000..a5b61c3
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/GSMHandler.py
@@ -0,0 +1,286 @@
+import ServerClass
+import GSMClass
+import LogFileClass
+from time import sleep
+import sys
+
+global portListen
+global portAddress
+
+
+if len(sys.argv) <> 3:
+ print "Error given command"
+ sys.exit(2)
+
+
+portListen = int(sys.argv[1])
+portAddress = sys.argv[2]
+
+def initLogfile():
+ global nameOfLogFile
+
+ if portListen == 50007:
+ nameOfLogFile = 'GSM RZ1 handler.log'
+
+ elif portListen == 50010:
+ nameOfLogFile = 'GSM O2 handler.log'
+
+ elif portListen == 50011:
+ nameOfLogFile = 'GSM Vodaphone handler.log'
+
+ elif portListen == 50012:
+ nameOfLogFile = 'GSM TMobile handler.log'
+
+ elif portListen == 50013:
+ nameOfLogFile = 'GSM EPlus handler.log'
+ else:
+ print "No port listening found"
+
+
+baudRate = 19200
+
+initLogfile()
+logger = LogFileClass.Logging(nameOfLogFile)
+
+errorCount = 0
+
+logger.logEvent('')
+
+whileCounter =0
+
+#define global varibales
+global lastState
+global resetState
+lastState = 0
+resetState = 0
+
+
+def initSystem():
+ print 'init system'
+
+ global handlerSocket
+ global gsmDevice
+ global initTalkVar
+ global lastState
+
+ global numberToCall
+ global resetState
+
+ initTalkVar = 0 #variable used to know if we initialized the start talk
+ lastState = 0 #variable used to know
+ numberToCall = '000' #number to call
+ resetState = 0
+
+ handlerSocket = ServerClass.ServerHandler(portListen)
+ logger.logEvent('LISTEN ON PORT: '+str(portListen))
+
+ #add this if you need it
+ gsmDevice = GSMClass.serialPort(portAddress, baudRate, 45)
+
+ initDevice = gsmDevice.portInit()
+ ########################################################
+
+ #add nice formating to the log file :)
+ anyConnection = handlerSocket.openSocket()
+
+
+ if anyConnection == 1 and initDevice == 1:
+ logger.logEvent('CONNECTION ESTABLISHED AND DEVICE WORKING: ' + str(handlerSocket.connectedTo()))
+ return 1
+
+ elif anyConnection == 1 and initDevice == 0:
+ logger.logEvent('$connection established but device not working: ' + str(handlerSocket.connectedTo()))
+ terminateConnection()
+ return 2
+ else:
+ logger.logEvent('$no connection')
+ sys.exit(1)
+ return 0
+
+def receiveMessage(timeout):
+
+ message = str(handlerSocket.receiveData(timeout))
+
+ if message != '0' and message !='NO DATA':
+ print 'in receive message', message, lastState
+
+ if message == 'HELLO HANDLER' and lastState == 0:
+ outcome = initTalk()
+ if outcome == 1:
+ logger.logEvent('TALK INITIALIZATION SENT')
+ else:
+ logger.logEvent('$talk initialization not sent: ' + str(outcome))
+
+ elif message == 'RECEIVER' and lastState == 1:
+ outcome = initReceiver()
+ if outcome == 1:
+ logger.logEvent('RECEIVER READY SENT')
+ else:
+ logger.logEvent('$receiver ready not sent: ' + str(outcome))
+
+ elif message == 'RECEIVE START' and lastState == 2:
+ outcome = receiveStart()
+ if outcome == 1:
+ logger.logEvent('RECEIVE STATUS REPORTED')
+ else:
+ logger.logEvent('$receive status not reported: ' + str(outcome))
+
+ elif message[0:6] == 'CALLER' and lastState == 1:
+ outcome = initCaller()
+
+ global numberToCall
+ numberToCall = message[7:]
+ if outcome == 1:
+ logger.logEvent('CALLER READY SENT')
+ else:
+ logger.logEvent('$caller ready not sent: ' + str(outcome))
+
+ elif message == 'CALL START' and lastState == 4:
+ outcome = callStart(numberToCall)
+ if outcome == 1:
+ logger.logEvent('CALLER STATUS SENT')
+ else:
+ logger.logEvent('$caller status not sent: ' + str(outcome))
+
+ elif message == 'TERMINATE CONNECTION' and (lastState == 5 or lastState == 3):
+ outcome = terminateConnection()
+ if outcome == 1:
+ logger.logEvent('TERMINATED THE CONNECTION AFTER TEST')
+ else:
+ logger.logEvent('$connection could not be terminated after the test: ' + str(outcome))
+
+ elif message == 'TERMINATE CONNECTION':
+ outcome = terminateConnection()
+ if outcome == 1:
+ logger.logEvent('TERMINATED THE CONNECTION IN MIDDLE. IN STATE: ' + str(lastState) )
+ else:
+ logger.logEvent('$connection could not be terminated in middle: ' + str(outcome) + ' in state: ' + str(lastState))
+ else:
+ outcome = other()
+ logger.logEvent('other appeared')
+ terminateConnection()
+
+
+ return 1
+ #return 0
+
+########INIT TALK PART########
+def initTalk():
+ print 'init talk'
+
+ #initialize the talk between handler and controller
+ global lastState
+ lastState = 1
+ sendMessage = handlerSocket.sendData('HELLO CONTROLLER')
+ return sendMessage
+##############################
+
+
+########RECEIVE PART########
+def initReceiver():
+ print 'initReceiver'
+
+ #init function to initialize the receiver
+ global lastState
+ lastState = 2
+ sendMessage = handlerSocket.sendData('RECEIVER READY')
+ return sendMessage
+
+def receiveStart():
+ print 'receiveStart'
+
+ #wait for a call and report if you received it and it was successfull or not
+ global lastState
+ lastState = 3
+ receiveCall = gsmDevice.receiveCall()
+
+ if receiveCall == 1:
+ callSuccess = 'CALL OK'
+ else:
+ callSuccess = 'CALL NOT OK'
+
+ tryHangUp = gsmDevice.hangUp()
+
+ sendMessage = handlerSocket.sendData(callSuccess)
+ return sendMessage
+############################
+
+
+########CALL PART########
+def initCaller():
+ print 'initCaller'
+
+ #initialize caller here
+ global lastState
+ lastState = 4
+ sendMessage = handlerSocket.sendData('CALLER READY')
+ return sendMessage
+
+def callStart(numberToCall):
+ print 'initCaller'
+
+ #call the number here
+ global lastState
+ lastState = 5
+
+ callSuccess = 'CALL NOT OK'
+
+ tryCall = gsmDevice.callNumber(numberToCall)
+ if tryCall != 1:
+ callSuccess = 'CALL NOT OK'
+ else:
+ sleep(2)
+ activeCall = gsmDevice.currentCall()
+ counter = 0
+ while(activeCall!=1):
+ sleep(1)
+ activeCall = gsmDevice.currentCall()
+ if counter == 6:
+ break
+ counter += 1
+
+ if activeCall == 1:
+ callSuccess = 'CALL OK'
+ else:
+ callSuccess = 'CALL NOT OK'
+
+ tryHangUp = gsmDevice.hangUp()
+
+ return handlerSocket.sendData(callSuccess)
+#########################
+
+
+########TERMINATE PART########
+def terminateConnection():
+ print 'terminate connection'
+ global resetState
+ close = handlerSocket.closeConnection()
+ resetState = 1
+ sys.exit(0.5)
+ return close
+##############################
+
+########TERMINATE PART########
+def other():
+ print 'other'
+ global lastState
+ global resetState
+
+ close = handlerSocket.closeConnection()
+ lastState = 8
+ resetState = 1
+ return 1
+##############################
+
+
+
+while 1:
+ test = initSystem()
+ if test == 1:
+ print 'initialized system'
+ receivedMessage = 0
+ while receivedMessage < 4 and resetState!= 1:
+ receivedMessage += receiveMessage(10)
+
+ del handlerSocket
+ del gsmDevice
diff --git a/For Weekly Test/Old/30-07-2011/Landline handler.log b/For Weekly Test/Old/30-07-2011/Landline handler.log
new file mode 100644
index 0000000..08456fb
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/Landline handler.log
@@ -0,0 +1,210 @@
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:26:27.189491 ------------------
+On: 2011-07-29 23:26:27.197636 Event: try to Connect to Controller
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:29:02.577881 ------------------
+On: 2011-07-29 23:29:02.588058 Event: try to Connect to Controller
+On: 2011-07-29 23:29:50.425808 Event: init state
+On: 2011-07-29 23:29:50.426527 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:31:11.685264 ------------------
+On: 2011-07-29 23:31:11.693752 Event: try to Connect to Controller
+On: 2011-07-29 23:31:50.356785 Event: init state
+On: 2011-07-29 23:31:50.357509 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:32:30.935401 ------------------
+On: 2011-07-29 23:32:30.944002 Event: try to Connect to Controller
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:38:34.265205 ------------------
+On: 2011-07-29 23:38:34.272929 Event: init state
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:39:05.071215 ------------------
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:39:35.502775 ------------------
+On: 2011-07-29 23:39:35.512507 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:41:23.875335 ------------------
+On: 2011-07-29 23:41:23.884532 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:42:13.341609 ------------------
+On: 2011-07-29 23:42:13.350064 Event: try to Connect to Controller
+On: 2011-07-29 23:42:16.203271 Event: init state
+On: 2011-07-29 23:42:16.203385 Event: Register Account to SIP server
+On: 2011-07-29 23:42:16.236148 Event: 100
+On: 2011-07-29 23:42:16.237396 Event: Receiver Handler Ready
+On: 2011-07-29 23:42:16.237455 Event: RECEIVE START
+On: 2011-07-29 23:42:24.127645 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-29 23:42:24.628790 Event: Call Connecting
+On: 2011-07-29 23:42:24.628835 Event: 200
+On: 2011-07-29 23:42:24.628978 Event: Answer call
+On: 2011-07-29 23:42:25.129584 Event: Hangup call
+On: 2011-07-29 23:42:25.129810 Event: CALL OK
+On: 2011-07-29 23:42:25.283094 Event: Call Disconnected
+On: 2011-07-29 23:42:25.393821 Event: Terminate
+On: 2011-07-29 23:42:25.393846 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:43:09.728877 ------------------
+On: 2011-07-29 23:43:09.736885 Event: try to Connect to Controller
+On: 2011-07-29 23:43:12.619960 Event: init state
+On: 2011-07-29 23:43:12.620108 Event: Register Account to SIP server
+On: 2011-07-29 23:43:12.667817 Event: 100
+On: 2011-07-29 23:43:12.669071 Event: Receiver Handler Ready
+On: 2011-07-29 23:43:12.669134 Event: RECEIVE START
+On: 2011-07-29 23:43:22.045718 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-29 23:43:22.546823 Event: Call Connecting
+On: 2011-07-29 23:43:22.546868 Event: 200
+On: 2011-07-29 23:43:22.547008 Event: Answer call
+On: 2011-07-29 23:43:23.047637 Event: Hangup call
+On: 2011-07-29 23:43:23.047873 Event: CALL OK
+On: 2011-07-29 23:43:23.101125 Event: Terminate
+On: 2011-07-29 23:43:23.101164 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:10:42.822564 ------------------
+On: 2011-07-30 00:10:42.830586 Event: try to Connect to Controller
+On: 2011-07-30 00:10:45.703646 Event: init state
+On: 2011-07-30 00:10:45.703811 Event: Register Account to SIP server
+On: 2011-07-30 00:10:45.737799 Event: 100
+On: 2011-07-30 00:10:45.737884 Event: Receiver Handler Ready
+On: 2011-07-30 00:10:45.738026 Event: RECEIVE START
+On: 2011-07-30 00:10:55.229448 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-30 00:10:55.730592 Event: Call Connecting
+On: 2011-07-30 00:10:55.730637 Event: 200
+On: 2011-07-30 00:10:55.730779 Event: Answer call
+On: 2011-07-30 00:10:56.231365 Event: Hangup call
+On: 2011-07-30 00:10:56.231546 Event: CALL OK
+On: 2011-07-30 00:10:56.333503 Event: Call Disconnected
+On: 2011-07-30 00:10:56.339227 Event: Terminate
+On: 2011-07-30 00:10:56.339270 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:11:35.034475 ------------------
+On: 2011-07-30 00:11:35.042598 Event: try to Connect to Controller
+On: 2011-07-30 00:11:37.902099 Event: init state
+On: 2011-07-30 00:11:37.902275 Event: Register Account to SIP server
+On: 2011-07-30 00:11:37.935993 Event: 100
+On: 2011-07-30 00:11:37.936061 Event: Receiver Handler Ready
+On: 2011-07-30 00:11:37.937281 Event: RECEIVE START
+On: 2011-07-30 00:12:19.237484 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-30 00:12:19.738583 Event: Call Connecting
+On: 2011-07-30 00:12:19.738627 Event: 200
+On: 2011-07-30 00:12:19.738772 Event: Answer call
+On: 2011-07-30 00:12:19.739148 Event: Terminate
+On: 2011-07-30 00:12:19.739188 Event: Goodbye
+On: 2011-07-30 00:12:20.239411 Event: Hangup call
+On: 2011-07-30 00:12:20.239637 Event: CALL OK
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:26:57.303984 ------------------
+On: 2011-07-30 00:26:57.313040 Event: try to Connect to Controller
+On: 2011-07-30 00:27:00.184213 Event: init state
+On: 2011-07-30 00:27:00.184461 Event: Register Account to SIP server
+On: 2011-07-30 00:27:00.218449 Event: 100
+On: 2011-07-30 00:27:00.218498 Event: Receiver Handler Ready
+On: 2011-07-30 00:27:00.218650 Event: RECEIVE START
+On: 2011-07-30 00:27:08.332497 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-30 00:27:08.833577 Event: Call Connecting
+On: 2011-07-30 00:27:08.833612 Event: 200
+On: 2011-07-30 00:27:08.833737 Event: Answer call
+On: 2011-07-30 00:27:09.334016 Event: Hangup call
+On: 2011-07-30 00:27:09.334160 Event: CALL OK
+On: 2011-07-30 00:27:09.487264 Event: Call Disconnected
+On: 2011-07-30 00:27:09.642374 Event: Terminate
+On: 2011-07-30 00:27:09.642418 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:28:01.427077 ------------------
+On: 2011-07-30 00:28:01.436400 Event: try to Connect to Controller
+On: 2011-07-30 00:28:04.292014 Event: init state
+On: 2011-07-30 00:28:04.292217 Event: Register Account to SIP server
+On: 2011-07-30 00:28:04.324649 Event: 100
+On: 2011-07-30 00:28:04.325843 Event: Receiver Handler Ready
+On: 2011-07-30 00:28:04.325903 Event: RECEIVE START
+On: 2011-07-30 00:28:13.702346 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-30 00:28:14.203385 Event: Call Connecting
+On: 2011-07-30 00:28:14.203417 Event: 200
+On: 2011-07-30 00:28:14.203537 Event: Answer call
+On: 2011-07-30 00:28:14.704140 Event: Hangup call
+On: 2011-07-30 00:28:14.704328 Event: CALL OK
+On: 2011-07-30 00:28:14.857462 Event: Call Disconnected
+On: 2011-07-30 00:28:15.222953 Event: Terminate
+On: 2011-07-30 00:28:15.222995 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:29:48.744168 ------------------
+On: 2011-07-30 00:29:48.752266 Event: try to Connect to Controller
+On: 2011-07-30 00:29:51.616628 Event: init state
+On: 2011-07-30 00:29:51.616869 Event: Register Account to SIP server
+On: 2011-07-30 00:29:51.652901 Event: 100
+On: 2011-07-30 00:29:51.654175 Event: Receiver Handler Ready
+On: 2011-07-30 00:29:51.654238 Event: RECEIVE START
+On: 2011-07-30 00:29:59.645670 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-30 00:30:00.146572 Event: Call Connecting
+On: 2011-07-30 00:30:00.146595 Event: 200
+On: 2011-07-30 00:30:00.146639 Event: Answer call
+On: 2011-07-30 00:30:01.000360 Event: Terminate
+On: 2011-07-30 00:30:01.000409 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:30:56.623124 ------------------
+On: 2011-07-30 00:30:56.633526 Event: try to Connect to Controller
+On: 2011-07-30 00:30:59.467030 Event: init state
+On: 2011-07-30 00:30:59.467207 Event: Register Account to SIP server
+On: 2011-07-30 00:30:59.514683 Event: 100
+On: 2011-07-30 00:30:59.515924 Event: Receiver Handler Ready
+On: 2011-07-30 00:30:59.515989 Event: RECEIVE START
+On: 2011-07-30 00:31:07.302992 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-30 00:31:07.303394 Event: Call Connecting
+On: 2011-07-30 00:31:07.303420 Event: 200
+On: 2011-07-30 00:31:07.303559 Event: Answer call
+On: 2011-07-30 00:31:07.303592 Event: Hangup call
+On: 2011-07-30 00:31:07.303717 Event: CALL OK
+On: 2011-07-30 00:31:07.456866 Event: Call Disconnected
+On: 2011-07-30 00:31:08.091116 Event: Terminate
+On: 2011-07-30 00:31:08.091163 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:32:36.381169 ------------------
+On: 2011-07-30 00:32:36.389505 Event: try to Connect to Controller
+On: 2011-07-30 00:32:39.254557 Event: init state
+On: 2011-07-30 00:32:39.254662 Event: Register Account to SIP server
+On: 2011-07-30 00:32:39.302100 Event: 100
+On: 2011-07-30 00:32:39.303401 Event: Receiver Handler Ready
+On: 2011-07-30 00:32:39.303465 Event: RECEIVE START
+On: 2011-07-30 00:32:45.346692 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-30 00:32:45.347091 Event: Call Connecting
+On: 2011-07-30 00:32:45.347129 Event: 200
+On: 2011-07-30 00:32:45.347287 Event: Answer call
+On: 2011-07-30 00:32:45.347323 Event: Hangup call
+On: 2011-07-30 00:32:45.347446 Event: CALL OK
+On: 2011-07-30 00:32:45.500536 Event: Call Disconnected
+On: 2011-07-30 00:32:46.218824 Event: Terminate
+On: 2011-07-30 00:32:46.218872 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:33:35.950284 ------------------
+On: 2011-07-30 00:33:35.958817 Event: try to Connect to Controller
+On: 2011-07-30 00:33:38.817673 Event: init state
+On: 2011-07-30 00:33:38.817826 Event: Register Account to SIP server
+On: 2011-07-30 00:33:38.865841 Event: 100
+On: 2011-07-30 00:33:38.865926 Event: Receiver Handler Ready
+On: 2011-07-30 00:33:38.867128 Event: RECEIVE START
+On: 2011-07-30 00:33:44.604232 Event: {Call "anonymous" <sip:anonymous@sipgate.de>}
+On: 2011-07-30 00:33:44.604630 Event: Call Connecting
+On: 2011-07-30 00:33:44.604652 Event: 200
+On: 2011-07-30 00:33:44.604820 Event: Answer call
+On: 2011-07-30 00:33:44.604848 Event: Hangup call
+On: 2011-07-30 00:33:44.604946 Event: CALL OK
+On: 2011-07-30 00:33:44.757964 Event: Call Disconnected
+On: 2011-07-30 00:33:45.465493 Event: Terminate
+On: 2011-07-30 00:33:45.465530 Event: Goodbye
diff --git a/For Weekly Test/Old/30-07-2011/LogFileClass.py b/For Weekly Test/Old/30-07-2011/LogFileClass.py
new file mode 100644
index 0000000..cb152f4
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/LogFileClass.py
@@ -0,0 +1,21 @@
+import string
+import datetime
+
+class Logging:
+
+ def __init__(self, logFileName):
+ self.writeToFile = open(logFileName, 'a')
+ self.justStarted = 1
+
+ def logEvent(self, event):
+ now = str(datetime.datetime.now())
+ if self.justStarted == 1:
+ self.writeToFile.write('\n\n------------------STARTED THE LOGGING '+ now + ' ------------------\n')
+ self.justStarted = 0
+ else:
+ self.writeToFile.write('On: '+ now + '\t' + 'Event: ' +str(event) + '\n')
+
+ def closeLogging(self):
+ now = str(datetime.datetime.now())
+ self.writeToFile.write('------------------FINISHED THE LOGGING '+ now + ' ------------------')
+ self.writeToFile.close()
diff --git a/For Weekly Test/Old/30-07-2011/LogFileClass.pyc b/For Weekly Test/Old/30-07-2011/LogFileClass.pyc
new file mode 100644
index 0000000..52fd946
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/LogFileClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/30-07-2011/PingClass.py b/For Weekly Test/Old/30-07-2011/PingClass.py
new file mode 100644
index 0000000..e13b32b
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/PingClass.py
@@ -0,0 +1,28 @@
+import subprocess
+import string
+
+class Ping:
+
+ def __init__(self, pingAddress):
+ self.pingAddress = pingAddress
+
+ def ping(self,numberTries):
+ tried = 1
+ while numberTries >= tried:
+ tried += 1
+ #the parameter c 1 means only one ping to be sent, parameter W 3 means how many seconds the time out should be, 3 seconds
+ ping_cmd = subprocess.Popen(['ping', self.pingAddress, '-c', '1', '-W', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ unknownHost = int(string.find(ping_cmd, 'unknown host'))
+
+
+ if pingAlive != -1:
+ break
+
+ if unknownHost != -1:
+ return 2 #unknown host
+ if pingAlive != -1:
+ return 1 #ping works fine
+ else:
+ return 0 #no ping response
diff --git a/For Weekly Test/Old/30-07-2011/PingClass.pyc b/For Weekly Test/Old/30-07-2011/PingClass.pyc
new file mode 100644
index 0000000..9ac5c4b
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/PingClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/30-07-2011/SIP handler.log b/For Weekly Test/Old/30-07-2011/SIP handler.log
new file mode 100644
index 0000000..ee0220b
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/SIP handler.log
@@ -0,0 +1,168 @@
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:21:57.415823 ------------------
+On: 2011-07-29 23:21:57.425345 Event: try to Connect to Controller
+On: 2011-07-29 23:22:00.306913 Event: init state
+On: 2011-07-29 23:22:00.307021 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:24:53.876724 ------------------
+On: 2011-07-29 23:24:53.884855 Event: try to Connect to Controller
+On: 2011-07-29 23:24:56.739250 Event: init state
+On: 2011-07-29 23:24:56.739367 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:25:11.922247 ------------------
+On: 2011-07-29 23:25:11.930374 Event: try to Connect to Controller
+On: 2011-07-29 23:25:14.776741 Event: init state
+On: 2011-07-29 23:25:14.776832 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:25:27.644319 ------------------
+On: 2011-07-29 23:25:27.654529 Event: try to Connect to Controller
+On: 2011-07-29 23:25:30.488887 Event: init state
+On: 2011-07-29 23:25:30.488998 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:26:15.433339 ------------------
+On: 2011-07-29 23:26:15.444299 Event: try to Connect to Controller
+On: 2011-07-29 23:26:18.276304 Event: init state
+On: 2011-07-29 23:26:18.276337 Event: Register Account to SIP server
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:42:10.319903 ------------------
+On: 2011-07-29 23:42:10.328198 Event: try to Connect to Controller
+On: 2011-07-29 23:42:13.196833 Event: init state
+On: 2011-07-29 23:42:13.197004 Event: Register Account to SIP server
+On: 2011-07-29 23:42:13.197373 Event: 100
+On: 2011-07-29 23:42:13.197448 Event: Caller Handler Ready
+On: 2011-07-29 23:42:21.238138 Event: CALL START
+On: 2011-07-29 23:42:21.238194 Event: Make a call to: 076145875681
+On: 2011-07-29 23:42:25.393438 Event: Call Connecting
+On: 2011-07-29 23:42:25.393485 Event: 200
+On: 2011-07-29 23:42:25.394043 Event: Terminate
+On: 2011-07-29 23:42:25.394074 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:43:06.750461 ------------------
+On: 2011-07-29 23:43:06.759085 Event: try to Connect to Controller
+On: 2011-07-29 23:43:09.613473 Event: init state
+On: 2011-07-29 23:43:09.613644 Event: Register Account to SIP server
+On: 2011-07-29 23:43:09.614010 Event: 100
+On: 2011-07-29 23:43:09.614061 Event: Caller Handler Ready
+On: 2011-07-29 23:43:17.673133 Event: CALL START
+On: 2011-07-29 23:43:17.673190 Event: Make a call to: 076145875681
+On: 2011-07-29 23:43:23.100719 Event: Call Connecting
+On: 2011-07-29 23:43:23.100753 Event: 200
+On: 2011-07-29 23:43:23.101544 Event: Terminate
+On: 2011-07-29 23:43:23.101576 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:10:39.836082 ------------------
+On: 2011-07-30 00:10:39.845051 Event: try to Connect to Controller
+On: 2011-07-30 00:10:42.697416 Event: init state
+On: 2011-07-30 00:10:42.697558 Event: Register Account to SIP server
+On: 2011-07-30 00:10:42.697908 Event: 100
+On: 2011-07-30 00:10:42.697990 Event: Caller Handler Ready
+On: 2011-07-30 00:10:50.739806 Event: CALL START
+On: 2011-07-30 00:10:50.739862 Event: Make a call to: 076145875681
+On: 2011-07-30 00:10:56.338263 Event: Call Connecting
+On: 2011-07-30 00:10:56.338295 Event: 200
+On: 2011-07-30 00:10:56.338926 Event: Terminate
+On: 2011-07-30 00:10:56.338971 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:11:32.044804 ------------------
+On: 2011-07-30 00:11:32.055384 Event: try to Connect to Controller
+On: 2011-07-30 00:11:34.895786 Event: init state
+On: 2011-07-30 00:11:34.895941 Event: Register Account to SIP server
+On: 2011-07-30 00:11:34.896327 Event: 100
+On: 2011-07-30 00:11:34.896381 Event: Caller Handler Ready
+On: 2011-07-30 00:11:42.941360 Event: CALL START
+On: 2011-07-30 00:11:42.941412 Event: Make a call to: 076145875681
+On: 2011-07-30 00:12:19.738871 Event: Terminate
+On: 2011-07-30 00:12:19.738916 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:26:54.311305 ------------------
+On: 2011-07-30 00:26:54.320356 Event: try to Connect to Controller
+On: 2011-07-30 00:26:57.176776 Event: init state
+On: 2011-07-30 00:26:57.176895 Event: Register Account to SIP server
+On: 2011-07-30 00:26:57.177196 Event: 100
+On: 2011-07-30 00:26:57.177239 Event: Caller Handler Ready
+On: 2011-07-30 00:27:05.219886 Event: CALL START
+On: 2011-07-30 00:27:05.219948 Event: Make a call to: 076145875681
+On: 2011-07-30 00:27:09.641501 Event: Call Connecting
+On: 2011-07-30 00:27:09.641557 Event: 200
+On: 2011-07-30 00:27:09.642486 Event: Terminate
+On: 2011-07-30 00:27:09.642523 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:27:58.409659 ------------------
+On: 2011-07-30 00:27:58.417830 Event: try to Connect to Controller
+On: 2011-07-30 00:28:01.285869 Event: init state
+On: 2011-07-30 00:28:01.286077 Event: Register Account to SIP server
+On: 2011-07-30 00:28:01.286389 Event: 100
+On: 2011-07-30 00:28:01.286431 Event: Caller Handler Ready
+On: 2011-07-30 00:28:09.329917 Event: CALL START
+On: 2011-07-30 00:28:09.329971 Event: Make a call to: 076145875681
+On: 2011-07-30 00:28:15.222548 Event: Call Connecting
+On: 2011-07-30 00:28:15.222589 Event: 200
+On: 2011-07-30 00:28:15.223404 Event: Terminate
+On: 2011-07-30 00:28:15.223435 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:29:45.720356 ------------------
+On: 2011-07-30 00:29:45.729640 Event: try to Connect to Controller
+On: 2011-07-30 00:29:48.610439 Event: init state
+On: 2011-07-30 00:29:48.610574 Event: Register Account to SIP server
+On: 2011-07-30 00:29:48.610890 Event: 100
+On: 2011-07-30 00:29:48.610932 Event: Caller Handler Ready
+On: 2011-07-30 00:29:56.654983 Event: CALL START
+On: 2011-07-30 00:29:56.655033 Event: Make a call to: 076145875681
+On: 2011-07-30 00:30:00.999654 Event: Call Connecting
+On: 2011-07-30 00:30:00.999696 Event: 200
+On: 2011-07-30 00:30:01.000381 Event: Terminate
+On: 2011-07-30 00:30:01.000414 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:30:53.582445 ------------------
+On: 2011-07-30 00:30:53.591399 Event: try to Connect to Controller
+On: 2011-07-30 00:30:56.463424 Event: init state
+On: 2011-07-30 00:30:56.463573 Event: Register Account to SIP server
+On: 2011-07-30 00:30:56.463798 Event: 100
+On: 2011-07-30 00:30:56.463820 Event: Caller Handler Ready
+On: 2011-07-30 00:31:04.516608 Event: CALL START
+On: 2011-07-30 00:31:04.516663 Event: Make a call to: 076145875681
+On: 2011-07-30 00:31:08.090713 Event: Call Connecting
+On: 2011-07-30 00:31:08.090759 Event: 200
+On: 2011-07-30 00:31:08.091467 Event: Terminate
+On: 2011-07-30 00:31:08.091499 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:32:33.354788 ------------------
+On: 2011-07-30 00:32:33.363048 Event: try to Connect to Controller
+On: 2011-07-30 00:32:36.248229 Event: init state
+On: 2011-07-30 00:32:36.248378 Event: Register Account to SIP server
+On: 2011-07-30 00:32:36.248733 Event: 100
+On: 2011-07-30 00:32:36.248833 Event: Caller Handler Ready
+On: 2011-07-30 00:32:42.303930 Event: CALL START
+On: 2011-07-30 00:32:42.303983 Event: Make a call to: 076145875681
+On: 2011-07-30 00:32:46.218329 Event: Call Connecting
+On: 2011-07-30 00:32:46.218374 Event: 200
+On: 2011-07-30 00:32:46.219139 Event: Terminate
+On: 2011-07-30 00:32:46.219177 Event: Goodbye
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:33:32.956715 ------------------
+On: 2011-07-30 00:33:32.965479 Event: try to Connect to Controller
+On: 2011-07-30 00:33:35.811340 Event: init state
+On: 2011-07-30 00:33:35.811482 Event: Register Account to SIP server
+On: 2011-07-30 00:33:35.811814 Event: 100
+On: 2011-07-30 00:33:35.811857 Event: Caller Handler Ready
+On: 2011-07-30 00:33:41.869229 Event: CALL START
+On: 2011-07-30 00:33:41.869282 Event: Make a call to: 076145875681
+On: 2011-07-30 00:33:45.465131 Event: Call Connecting
+On: 2011-07-30 00:33:45.465173 Event: 200
+On: 2011-07-30 00:33:45.465887 Event: Terminate
+On: 2011-07-30 00:33:45.465913 Event: Goodbye
diff --git a/For Weekly Test/Old/30-07-2011/SIPHandler.py b/For Weekly Test/Old/30-07-2011/SIPHandler.py
new file mode 100644
index 0000000..6d268a9
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/SIPHandler.py
@@ -0,0 +1,229 @@
+import sys
+import string
+import pjsua as pj
+import ServerClass
+import LogFileClass
+
+from time import sleep
+
+def log_cb(level, str, len):
+ print "--------starting Handler--------"
+
+# Receive events from incoming Call
+class Account(pj.AccountCallback):
+
+ def on_incoming_call(self, call):
+ global current_call
+
+ current_call = call
+ call_cb = Calling(current_call)
+ current_call.set_callback(call_cb)
+
+ logger.logEvent(current_call)
+
+ call.answer(200)
+ logger.logEvent("Answer call")
+
+ if current_call <> None:
+ logger.logEvent("Hangup call")
+ call.hangup()
+
+ logger.logEvent('CALL OK')
+
+class Calling(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+ def on_state(self):
+ global current_call
+
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ if self.call.info().state_text == "CONNECTING":
+ logger.logEvent("Call Connecting")
+ logger.logEvent('200')
+ server.sendData('CALL OK')
+
+ if self.call.info().last_reason == "Busy Here":
+ logger.logEvent('Number busy or Offline')
+ server.sendData('CALL NOT OK')
+ logger.logEvent('CALL NOT OK')
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ logger.logEvent('Call Disconnected')
+ current_call = None
+
+
+def make_call(uri):
+
+ try:
+
+ cb=Calling()
+ return acc.make_call(uri, cb)
+
+ except pj.Error, e:
+ print "408 " + str(e)
+ logger.logEvent('408')
+ return None
+
+def greeting():
+ global server
+ global status
+ global port
+
+ port = sys.argv[2]
+ server = None
+ status = None
+
+ server = ServerClass.ServerHandler(port)
+ logger.logEvent('try to Connect to Controller')
+ conn = server.openSocket()
+
+ if server.connected == 1:
+ if server.receiveData(30) == 'HELLO HANDLER':
+ server.sendData('HELLO CONTROLLER')
+ status = 'OK'
+ else:
+ status = 'NOT OK'
+ logger.logEvent('Cant connect to Controller')
+ sys.exit(1)
+
+def initLogFile(sipServer):
+
+ global logger
+
+ if sipServer == '132.230.4.8':
+ nameOfLogFile = 'SIP handler.log'
+
+ elif sipServer == 'sipgate.de':
+ nameOfLogFile = 'Landline handler.log'
+
+ elif sipServer == '132.230.252.228':
+ nameOfLogFile = 'University SIP handler.log'
+
+ logger = LogFileClass.Logging(nameOfLogFile)
+
+def initState():
+ global message
+ global state
+ global num
+
+ logger.logEvent('init state')
+ message = server.receiveData(30)
+
+ if message == 'RECEIVER':
+ state = 'RECEIVER'
+
+ elif message[0:6] == 'CALLER':
+ state = 'CALLER'
+ num = message[7:]
+
+def initHandler():
+ global sipServer
+ global username
+ global password
+
+
+ accConf = sys.argv[1]
+ username = accConf[0:accConf.find(':')]
+
+ line = accConf[accConf.find(':')+1:]
+ password = line[0:line.find(':')]
+
+ newLine = line[line.find(':')+1:]
+ sipServer = newLine[0:newLine.find(':')]
+
+
+lib = pj.Lib()
+stop = False
+
+initHandler()
+
+initLogFile(sipServer)
+
+logger.logEvent('')
+
+while stop <> True:
+
+ acc_cfg = None
+
+ lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+ greeting()
+
+
+ try:
+ initState()
+ acc_cfg = pj.AccountConfig(str(sipServer),str(username),str(password))
+ logger.logEvent('Register Account to SIP server')
+ acc = lib.create_account(acc_cfg, cb=Account())
+
+ if acc.info().reg_status < 700:
+
+ if state =='RECEIVER':
+ logger.logEvent(acc.info().reg_status)
+ server.sendData('RECEIVER READY')
+ logger.logEvent('Receiver Handler Ready')
+
+ while 1:
+
+ data = server.receiveData(1)
+
+ if data == 'RECEIVE START':
+ logger.logEvent(data)
+
+ if data == 'TERMINATE CONNECTION':
+ logger.logEvent('Terminate')
+ stop = True
+ break
+
+ elif state =='CALLER':
+ logger.logEvent(acc.info().reg_status)
+ server.sendData('CALLER READY')
+ logger.logEvent('Caller Handler Ready')
+
+ while 1:
+
+ data = server.receiveData(1)
+
+ if data == 'CALL START':
+ if num <> '':
+ sleep(3)
+ logger.logEvent(data)
+ logger.logEvent('Make a call to: ' + num)
+ number = "sip:"+num+"@"+sipServer
+ make_call(number)
+ else:
+ logger.logEvent('No number to call')
+ logger.logEvent('CALL NOT OK')
+
+ if data == 'TERMINATE CONNECTION':
+ stop = True
+ logger.logEvent('Terminate')
+ break
+
+ else:
+ logger.logEvent('Unknow Message')
+ server.sendData('Unknow Message')
+ server.closeConnection()
+ sys.exit(0.5)
+
+ else:
+ logger.logEvent("488 Not Acceptable Here")
+ lib.destroy()
+
+ except ValueError:
+ print "401 Unauthorized " + str(e)
+ logger.logEvent("401 Unauthorized ")
+
+logger.logEvent("Goodbye")
+acc.delete()
+lib.destroy()
+server.closeConnection()
+lib = None
+acc = None
+
diff --git a/For Weekly Test/Old/30-07-2011/ServerClass.py b/For Weekly Test/Old/30-07-2011/ServerClass.py
new file mode 100644
index 0000000..93c2f8e
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/ServerClass.py
@@ -0,0 +1,152 @@
+import socket
+import sys
+import os
+import string
+import signal
+
+class TimeoutException(Exception):
+ pass
+
+class ServerHandler:
+
+ def __init__(self,p):
+ self.port = p
+ self.host = None #symbolic name meaning all available interfaces
+ self.s = None
+ self.connected = 0
+ self.address = "127.0.0.1" #address of the main controller
+ self.onceConnected = 0
+ self.error = 'No error'
+
+ self.debugMode = 0
+
+ def openSocket(self):
+ self.error = 'No error'
+ for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC,
+ socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
+ af, socktype, proto, canonname, sa = res
+
+ try:
+ self.s = socket.socket(af, socktype, proto)
+ self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets
+ except socket.error, msg:
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+
+ try:
+ self.s.bind(sa)
+ self.s.listen(1)
+ except socket.error, msg:
+ self.s.close()
+ self.s = None
+ self.connected = 0
+ self.error = str(msg)
+ continue
+ break
+
+ if self.s is None:
+ self.connected = 0
+ return 0
+ else: #accept the connection
+ self.connection, self.address = self.s.accept()
+ self.connected = 1
+ self.onceConnected = 1
+ return 1
+
+ def connectedTo(self):
+ return self.address
+
+ def receiveData(self, timeout):
+ if self.connected == 1:
+
+ def timeout_handler(signum, frame):
+ raise TimeoutException()
+
+ try:
+
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(timeout) #start the timeout alarm, for timeout seconds
+
+ data = self.connection.recv(1024)
+
+ #stop the timeout function
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ if not data:
+ self.connected = 0
+ return 'NO DATA'
+ else:
+ return data
+
+ except TimeoutException:
+ #timeout happened
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ return 'TIMEOUT'
+
+ except Exception, e:
+ #stop the timeout timer
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connected = 0
+ if error[0:11] == '[Errno 104]':
+ return 3 #the other side reset the connection,[Errno 104] Connection reset by peer
+
+ return 2
+ else:
+ return 0
+
+ def sendData(self, data):
+ if self.connected == 1:
+ try:
+ self.connection.send(data)
+ return 1
+
+ except Exception, e:
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ self.connecected = 0
+ return 2
+ else:
+ return 0
+
+ def closeConnection(self):
+ if self.onceConnected == 1:
+ try:
+ self.connected = 0
+ SHUT_RDWR = 2
+ self.connection.shutdown(SHUT_RDWR)
+ self.connection.close()
+ return 1
+ except Exception, e:
+ self.connected = 0
+ error = str(e)
+ if self.debugMode == 1:
+ import traceback
+ print traceback.format_exc()
+ print e
+ if error[0:11] == '[Errno 107]':
+ return 3 #the other side closed the connection before us [Errno 107] Transport endpoint is not connected
+ return 2
+ else:
+ return 0
+
+ def killPort(self):
+ killResult = os.popen('lsof -i tcp:' + str(self.port) + ' | grep "python " | awk -F" " ' + "'{print $2}'").read()
+ killResult = killResult.replace('\n','')
+ print killResult
+ if killResult!='':
+ print killResult
+ killPort = os.popen("kill -9 " + killResult).read()
+ return 1
+ return 0
diff --git a/For Weekly Test/Old/30-07-2011/ServerClass.pyc b/For Weekly Test/Old/30-07-2011/ServerClass.pyc
new file mode 100644
index 0000000..99bd14d
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/ServerClass.pyc
Binary files differ
diff --git a/For Weekly Test/Old/30-07-2011/TestProcessLog.log b/For Weekly Test/Old/30-07-2011/TestProcessLog.log
new file mode 100644
index 0000000..4826295
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/TestProcessLog.log
@@ -0,0 +1,200 @@
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:21:57.301030 ------------------
+On: 2011-07-29 23:21:57.301097 Event: init Caller
+On: 2011-07-29 23:21:57.301117 Event: sip
+On: 2011-07-29 23:22:00.306750 Event: Connected to Caller Handler
+On: 2011-07-29 23:22:00.306934 Event: Caller Handler respond
+On: 2011-07-29 23:22:00.330494 Event: 605 General Handler Error: caller handler no respond timeout
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:24:53.733342 ------------------
+On: 2011-07-29 23:24:53.733408 Event: init Caller
+On: 2011-07-29 23:24:53.733427 Event: sip
+On: 2011-07-29 23:24:56.739075 Event: Connected to Caller Handler
+On: 2011-07-29 23:24:56.739283 Event: Caller Handler respond
+On: 2011-07-29 23:24:56.743416 Event: 605 General Handler Error: caller handler no respond timeout
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:25:11.770967 ------------------
+On: 2011-07-29 23:25:11.771004 Event: init Caller
+On: 2011-07-29 23:25:11.771011 Event: sip
+On: 2011-07-29 23:25:14.776562 Event: Connected to Caller Handler
+On: 2011-07-29 23:25:14.776759 Event: Caller Handler respond
+On: 2011-07-29 23:25:14.778543 Event: 605 General Handler Error: caller handler no respond timeout
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:25:27.483948 ------------------
+On: 2011-07-29 23:25:27.484014 Event: init Caller
+On: 2011-07-29 23:25:27.484034 Event: sip
+On: 2011-07-29 23:25:30.488703 Event: Connected to Caller Handler
+On: 2011-07-29 23:25:30.488907 Event: Caller Handler respond
+On: 2011-07-29 23:25:30.492889 Event: 605 General Handler Error: caller handler no respond timeout
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:26:15.270712 ------------------
+On: 2011-07-29 23:26:15.270780 Event: init Caller
+On: 2011-07-29 23:26:15.270799 Event: sip
+On: 2011-07-29 23:26:18.276198 Event: Connected to Caller Handler
+On: 2011-07-29 23:26:18.276306 Event: Caller Handler respond
+On: 2011-07-29 23:26:18.279521 Event: 605 General Handler Error: caller handler no respond timeout
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:42:10.192780 ------------------
+On: 2011-07-29 23:42:10.192869 Event: init Caller
+On: 2011-07-29 23:42:10.192901 Event: sip
+On: 2011-07-29 23:42:13.196666 Event: Connected to Caller Handler
+On: 2011-07-29 23:42:13.196857 Event: Caller Handler respond
+On: 2011-07-29 23:42:13.197492 Event: Caller handler : Ready
+On: 2011-07-29 23:42:13.197523 Event: init Receiver
+On: 2011-07-29 23:42:13.197551 Event: landline
+On: 2011-07-29 23:42:16.203095 Event: Connected to Receiver Handler
+On: 2011-07-29 23:42:16.203292 Event: Receiver Handler respond
+On: 2011-07-29 23:42:16.236357 Event: Receiver handler : Ready
+On: 2011-07-29 23:42:16.236397 Event: Start Call
+On: 2011-07-29 23:42:16.236480 Event: Waiting Feedback
+On: 2011-07-29 23:42:25.393704 Event: Test Succeed
+
+
+------------------STARTED THE LOGGING 2011-07-29 23:43:06.607570 ------------------
+On: 2011-07-29 23:43:06.607634 Event: init Caller
+On: 2011-07-29 23:43:06.607654 Event: sip
+On: 2011-07-29 23:43:09.613314 Event: Connected to Caller Handler
+On: 2011-07-29 23:43:09.613504 Event: Caller Handler respond
+On: 2011-07-29 23:43:09.614142 Event: Caller handler : Ready
+On: 2011-07-29 23:43:09.614180 Event: init Receiver
+On: 2011-07-29 23:43:09.614210 Event: landline
+On: 2011-07-29 23:43:12.619780 Event: Connected to Receiver Handler
+On: 2011-07-29 23:43:12.619981 Event: Receiver Handler respond
+On: 2011-07-29 23:43:12.667920 Event: Receiver handler : Ready
+On: 2011-07-29 23:43:12.667952 Event: Start Call
+On: 2011-07-29 23:43:12.668021 Event: Waiting Feedback
+On: 2011-07-29 23:43:23.100908 Event: Test Succeed
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:10:39.691500 ------------------
+On: 2011-07-30 00:10:39.691562 Event: init Caller
+On: 2011-07-30 00:10:39.691581 Event: sip
+On: 2011-07-30 00:10:42.697234 Event: Connected to Caller Handler
+On: 2011-07-30 00:10:42.697433 Event: Caller Handler respond
+On: 2011-07-30 00:10:42.698013 Event: Caller handler : Ready
+On: 2011-07-30 00:10:42.698050 Event: init Receiver
+On: 2011-07-30 00:10:42.698078 Event: landline
+On: 2011-07-30 00:10:45.703491 Event: Connected to Receiver Handler
+On: 2011-07-30 00:10:45.703670 Event: Receiver Handler respond
+On: 2011-07-30 00:10:45.737912 Event: Receiver handler : Ready
+On: 2011-07-30 00:10:45.737950 Event: Start Call
+On: 2011-07-30 00:10:45.738028 Event: Waiting Feedback
+On: 2011-07-30 00:10:56.338452 Event: Test Succeed
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:11:31.889910 ------------------
+On: 2011-07-30 00:11:31.889974 Event: init Caller
+On: 2011-07-30 00:11:31.889994 Event: sip
+On: 2011-07-30 00:11:34.895578 Event: Connected to Caller Handler
+On: 2011-07-30 00:11:34.895803 Event: Caller Handler respond
+On: 2011-07-30 00:11:34.896404 Event: Caller handler : Ready
+On: 2011-07-30 00:11:34.896442 Event: init Receiver
+On: 2011-07-30 00:11:34.896471 Event: landline
+On: 2011-07-30 00:11:37.901943 Event: Connected to Receiver Handler
+On: 2011-07-30 00:11:37.902124 Event: Receiver Handler respond
+On: 2011-07-30 00:11:37.936091 Event: Receiver handler : Ready
+On: 2011-07-30 00:11:37.936130 Event: Start Call
+On: 2011-07-30 00:11:37.936214 Event: Waiting Feedback
+On: 2011-07-30 00:12:19.738731 Event: Test Failed
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:26:54.171248 ------------------
+On: 2011-07-30 00:26:54.171301 Event: init Caller
+On: 2011-07-30 00:26:54.171316 Event: sip
+On: 2011-07-30 00:26:57.176620 Event: Connected to Caller Handler
+On: 2011-07-30 00:26:57.176790 Event: Caller Handler respond
+On: 2011-07-30 00:26:57.177313 Event: Caller handler : Ready
+On: 2011-07-30 00:26:57.177342 Event: init Receiver
+On: 2011-07-30 00:26:57.177362 Event: landline
+On: 2011-07-30 00:27:00.183045 Event: Connected to Receiver Handler
+On: 2011-07-30 00:27:00.184305 Event: Receiver Handler respond
+On: 2011-07-30 00:27:00.218555 Event: Receiver handler : Ready
+On: 2011-07-30 00:27:00.218586 Event: Start Call
+On: 2011-07-30 00:27:00.218653 Event: Waiting Feedback
+On: 2011-07-30 00:27:09.641743 Event: Test Succeed
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:27:58.280395 ------------------
+On: 2011-07-30 00:27:58.280448 Event: init Caller
+On: 2011-07-30 00:27:58.280464 Event: sip
+On: 2011-07-30 00:28:01.285723 Event: Connected to Caller Handler
+On: 2011-07-30 00:28:01.285934 Event: Caller Handler respond
+On: 2011-07-30 00:28:01.286508 Event: Caller handler : Ready
+On: 2011-07-30 00:28:01.286540 Event: init Receiver
+On: 2011-07-30 00:28:01.286565 Event: landline
+On: 2011-07-30 00:28:04.291863 Event: Connected to Receiver Handler
+On: 2011-07-30 00:28:04.292049 Event: Receiver Handler respond
+On: 2011-07-30 00:28:04.324731 Event: Receiver handler : Ready
+On: 2011-07-30 00:28:04.324758 Event: Start Call
+On: 2011-07-30 00:28:04.324809 Event: Waiting Feedback
+On: 2011-07-30 00:28:15.222749 Event: Test Succeed
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:29:45.604794 ------------------
+On: 2011-07-30 00:29:45.604849 Event: init Caller
+On: 2011-07-30 00:29:45.604865 Event: sip
+On: 2011-07-30 00:29:48.610293 Event: Connected to Caller Handler
+On: 2011-07-30 00:29:48.610457 Event: Caller Handler respond
+On: 2011-07-30 00:29:48.610961 Event: Caller handler : Ready
+On: 2011-07-30 00:29:48.610988 Event: init Receiver
+On: 2011-07-30 00:29:48.611012 Event: landline
+On: 2011-07-30 00:29:51.616488 Event: Connected to Receiver Handler
+On: 2011-07-30 00:29:51.616698 Event: Receiver Handler respond
+On: 2011-07-30 00:29:51.653007 Event: Receiver handler : Ready
+On: 2011-07-30 00:29:51.653033 Event: Start Call
+On: 2011-07-30 00:29:51.653089 Event: Waiting Feedback
+On: 2011-07-30 00:30:00.999843 Event: Test Succeed
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:30:53.455843 ------------------
+On: 2011-07-30 00:30:53.455927 Event: init Caller
+On: 2011-07-30 00:30:53.455956 Event: sip
+On: 2011-07-30 00:30:56.462075 Event: Connected to Caller Handler
+On: 2011-07-30 00:30:56.463454 Event: Caller Handler respond
+On: 2011-07-30 00:30:56.463833 Event: Caller handler : Ready
+On: 2011-07-30 00:30:56.463851 Event: init Receiver
+On: 2011-07-30 00:30:56.463864 Event: landline
+On: 2011-07-30 00:30:59.466866 Event: Connected to Receiver Handler
+On: 2011-07-30 00:30:59.467064 Event: Receiver Handler respond
+On: 2011-07-30 00:30:59.514807 Event: Receiver handler : Ready
+On: 2011-07-30 00:30:59.514840 Event: Start Call
+On: 2011-07-30 00:30:59.514905 Event: Waiting Feedback
+On: 2011-07-30 00:31:08.090937 Event: Test Succeed
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:32:33.242689 ------------------
+On: 2011-07-30 00:32:33.242743 Event: init Caller
+On: 2011-07-30 00:32:33.242759 Event: sip
+On: 2011-07-30 00:32:36.248041 Event: Connected to Caller Handler
+On: 2011-07-30 00:32:36.248249 Event: Caller Handler respond
+On: 2011-07-30 00:32:36.248856 Event: Caller handler : Ready
+On: 2011-07-30 00:32:36.248896 Event: init Receiver
+On: 2011-07-30 00:32:36.248923 Event: landline
+On: 2011-07-30 00:32:39.254384 Event: Connected to Receiver Handler
+On: 2011-07-30 00:32:39.254580 Event: Receiver Handler respond
+On: 2011-07-30 00:32:39.302242 Event: Receiver handler : Ready
+On: 2011-07-30 00:32:39.302269 Event: Start Call
+On: 2011-07-30 00:32:39.302328 Event: Waiting Feedback
+On: 2011-07-30 00:32:46.218668 Event: Test Succeed
+
+
+------------------STARTED THE LOGGING 2011-07-30 00:33:32.805854 ------------------
+On: 2011-07-30 00:33:32.805907 Event: init Caller
+On: 2011-07-30 00:33:32.805923 Event: sip
+On: 2011-07-30 00:33:35.811199 Event: Connected to Caller Handler
+On: 2011-07-30 00:33:35.811359 Event: Caller Handler respond
+On: 2011-07-30 00:33:35.811924 Event: Caller handler : Ready
+On: 2011-07-30 00:33:35.812014 Event: init Receiver
+On: 2011-07-30 00:33:35.812040 Event: landline
+On: 2011-07-30 00:33:38.817500 Event: Connected to Receiver Handler
+On: 2011-07-30 00:33:38.817694 Event: Receiver Handler respond
+On: 2011-07-30 00:33:38.865974 Event: Receiver handler : Ready
+On: 2011-07-30 00:33:38.866013 Event: Start Call
+On: 2011-07-30 00:33:38.866098 Event: Waiting Feedback
+On: 2011-07-30 00:33:45.465315 Event: Test Succeed
diff --git a/For Weekly Test/Old/30-07-2011/gsmselftest.py b/For Weekly Test/Old/30-07-2011/gsmselftest.py
new file mode 100644
index 0000000..f8a385c
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/gsmselftest.py
@@ -0,0 +1,293 @@
+#! /usr/bin/env python
+import sys
+import ControllerClass
+import DbClass
+import PingClass
+from time import sleep
+
+def ping(handler):
+
+ global serverStatus
+
+ if handler == 'landline':
+ server = PingClass.Ping('sipgate.de')
+ serverStatus = server.ping(1)
+
+ elif handler == 'sip':
+ server = PingClass.Ping('132.230.4.8')
+ serverStatus = server.ping(1)
+
+ elif handler == 'unisip':
+ server = PingClass.Ping('132.230.252.228')
+ serverStatus = server.ping(1)
+
+ elif handler == 'gsmr1':
+ server = PingClass.Ping('localhost')
+ serverStatus = server.ping(1)
+
+ elif handler == 'gsmr2':
+ server = PingClass.Ping('132.230.4.64')
+ serverStatus = server.ping(1)
+ else:
+ serverStatus = 1
+
+def allPing():
+
+ global sipGate
+ global sipServer
+ global sipLoc
+ global gsmBox1
+ global gsmBox2
+
+ server = PingClass.Ping('sipgate.de')
+ sipGate = server.ping(3)
+
+ server = PingClass.Ping('132.230.4.8')
+ sipServer = server.ping(3)
+
+ server = PingClass.Ping('132.230.252.228')
+ sipLoc = server.ping(3)
+
+ server = PingClass.Ping('localhost')
+ gsmBox1 = server.ping(3)
+
+ server = PingClass.Ping('132.230.4.64')
+ gsmBox2 = server.ping(3)
+
+
+def doTest(callFrom,callTo):
+
+
+ global testRepeat
+
+ testRepeat = None
+ ping(callFrom)
+
+ db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
+ db.connectDB()
+ dbStatus = db.connectDB()
+
+
+ if serverStatus <> 0 and dbStatus == 1:
+
+ ping(callTo)
+ if serverStatus <> 0:
+ destination = db.deviceAddress(str(callTo))
+ caller = db.deviceAddress(str(callFrom))
+
+ callAdd = caller[0]
+ accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':'
+
+ recAdd = destination[0]
+ destNo = destination[1]
+ accDest = destination[2]+':'+destination[3]+':'+destination[4]+':'
+
+ print '\n'
+ print 'Caller :', callFrom
+ print 'Destination :', callTo
+ makeTest = ControllerClass.test(callFrom, callAdd, accCaller, callTo, recAdd, destNo, accDest)
+ makeTest.FuncTest()
+
+ if makeTest.repeatTest == True:
+ testRepeat = True
+ db.errorCode(makeTest.testResult)
+ print 'Result : ' +str(makeTest.testResult)+ ' ' +db.errCode
+ sleep(5)
+ else:
+ print '[failed] 500 '+callTo+ ' Server Internal Error'
+ else:
+ print '[failed] 500 '+callFrom+ ' Server Internal Error'
+
+def doSipTest():
+
+ print '--SIP Part Test--'
+ #destList = ['sip', 'gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'gsmeO', 'gsmeV', 'gsmeT', 'gsmeE']
+ destList = ['landline']
+ for callTo in destList:
+
+ callFrom = 'sip'
+ if callFrom <> callTo:
+ doTest(callFrom, callTo)
+ if testRepeat == True:
+ doTest(callTo,callFrom)
+
+def doLandlineTest():
+
+ print '--Landline Part Test--'
+ destList = ['gsmr1', 'gsmr2', 'gsmr3', 'sip']
+
+ for callTo in destList:
+
+ callFrom = 'landline'
+ doTest(callFrom, callTo)
+ if testRepeat == True:
+ doTest(callTo,callFrom)
+
+def doGsmrzTest():
+
+ print '--GSM Part Test--'
+ destList = ['sip', 'gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'gsmeO', 'gsmeV', 'gsmeT', 'gsmeE']
+ callList = ['gsmr1','gsmr2', 'gsmr3']
+
+ for callFrom in callList:
+
+ for callTo in destList:
+ if callTo <> callFrom:
+ doTest(callFrom, callTo)
+ if testRepeat == True:
+ doTest(callTo,callFrom)
+
+ doGsmExtTest()
+
+def doGsmExtTest():
+
+ destList = ['sip', 'gsmr1','gsmr2', 'gsmr3']
+ callList = ['gsmeO', 'gsmeV', 'gsmeT', 'gsmeE']
+
+ for callFrom in callList:
+ for callTo in destList:
+
+ doTest(callFrom, callTo)
+ if testRepeat == True:
+ doTest(callTo,callFrom)
+
+def initResult(i, result):
+ global resultsList
+
+
+
+
+def doAllTest():
+
+ doSipTest()
+ doLandlineTest()
+ doGsmTest()
+
+if len(sys.argv) > 1:
+
+ command = sys.argv[1]
+ print '\n'
+
+ if command == '--all':
+ doAllTest()
+
+ elif command == '--sip':
+ doSipTest()
+
+ elif command == '--gsm':
+ doGsmTest()
+
+ elif command == '--landline':
+ doLandlineTest()
+
+ elif command == '--help':
+ file = open('help.txt', 'r')
+ print file.read()
+
+ else:
+ print "command not found, Type '--help', '--credits' for more information."
+ print '\n'
+else:
+ global resultList
+ print '\n'
+ db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
+ db.connectDB()
+ dbStatus = db.connectDB()
+ resultsList = list()
+
+ if dbStatus == 1:
+
+ if db.anyTasksToDo() == 1:
+
+ #allPing()
+ i=0
+ for item in db.tasksList:
+ print item
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item[3]
+ tried = item[4]
+
+ destination = db.deviceAddress(str(callTo))
+
+ caller = db.deviceAddress(str(callFrom))
+
+ callAdd = caller[0]
+ accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':'
+
+ recAdd = destination[0]
+ destNo = destination[1]
+ accDest = destination[2]+':'+destination[3]+':'+destination[4]+':'
+
+ #if i == 0:
+ # db.updatePingResult(taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2)
+ print '\n'
+ print 'Task ID :', taskID
+ print 'Calling From :', callFrom
+ print 'To :', callTo
+ print 'number :', destNo
+ print 'status :', tried
+
+ ping(callFrom)
+
+ if serverStatus <> 0:
+
+ ping(callTo)
+ if serverStatus <> 0:
+
+ makeTest = ControllerClass.test(callFrom, callAdd, accCaller, callTo, recAdd, destNo, accDest)
+ makeTest.FuncTest()
+
+ db.addResult(taskID, makeTest.testResult)
+ resultList.append([callTo, callFrom, makeTest.testResult])
+
+ if makeTest.repeatTest == True and tried <> '1':
+ db.insertTaskIn2(callTo,callFrom,taskNo, '1')
+
+ db.errorCode(makeTest.testResult)
+ print 'Result : ' +str(makeTest.testResult)+ ' ' +db.errCode
+
+ db.deleteTempTask(taskID)
+ db.tasksList.remove(item)
+ db.tasksList.insert(i,'')
+
+ i = i+1
+
+ sleep(5)
+ else:
+ db.addResult(taskID, '500')
+ print '[failed] 500 '+callTo+ ' Server Internal Error'
+ else:
+ db.addResult(taskID, '500')
+ print '[failed] 500 '+callFrom+' Server Internal Error'
+ db.cleanTasksList()
+ else:
+ print "No job at all"
+ else:
+ sys.exit(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/For Weekly Test/Old/30-07-2011/help.txt b/For Weekly Test/Old/30-07-2011/help.txt
new file mode 100644
index 0000000..ccbc193
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/help.txt
@@ -0,0 +1,11 @@
+
+
+Usage: python gsmselftest.py [option]
+
+Options and arguments (and corresponding environment variables):
+
+--all : To execute all test case
+--sip : To execute ALL test case
+--gsm : To execute GSM test case
+--extGsm : To execute external GSM test case
+--landline : To execute Landline test case
diff --git a/For Weekly Test/Old/30-07-2011/true table.txt b/For Weekly Test/Old/30-07-2011/true table.txt
new file mode 100644
index 0000000..5a5916b
--- /dev/null
+++ b/For Weekly Test/Old/30-07-2011/true table.txt
@@ -0,0 +1,43 @@
+if GSMRZ1 != 200:
+ if GSMRZ2 = 200:
+ if GSMRZ3 == 200:
+ BTS RZ 1 problem
+ else:
+ unknow problem
+ elif GSMRZ3 == 200:
+ if GSMRZ2 == 200:
+ BTS RZ 1 Problem
+ else:
+ unknow problem
+ else:
+ OpenBSC problem
+
+if GSMRZ2 != 200:
+ if GSMRZ1 = 200:
+ if GSMRZ3 == 200:
+ BTS RZ 2 problem
+ else:
+ unknow problem
+ elif GSMRZ3 == 200:
+ if GSMRZ1 == 200:
+ BTS RZ 2 Problem
+ else:
+ unknow problem
+ else:
+ OpenBSC problem
+
+if GSMRZ3 != 200:
+ if GSMRZ1 = 200:
+ if GSMRZ2 == 200:
+ BTS RZ 3 problem
+ else:
+ unknow problem
+ elif GSMRZ2 == 200:
+ if GSMRZ1 == 200:
+ BTS RZ 3 Problem
+ else:
+ unknow problem
+ else:
+ OpenBSC problem
+
+