-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcstatest.py
More file actions
executable file
·83 lines (67 loc) · 1.73 KB
/
cstatest.py
File metadata and controls
executable file
·83 lines (67 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/python
import socket
import select
import types
import time
import pgdb
import messclient
import sys
import phonesystem
indebug = 0
outdebug = 0
testing=0
server = None
if testing:
server = messclient.messclient(myname='Phone',myuser="TestPhone")
group= "testphone"
else:
server = messclient.messclient(myname='Phone',myuser="Phone")
group = "phone"
messclient.status="Phone System Startup"
server.join(group)
server.join(group+"ping")
mydb = None
if not testing:
mydb = pgdb.connect(database="express",host="dbaseserver",user="sts")
else:
mydb = pgdb.connect(database="express",host="testserver",user="sts")
if mydb:
cur = mydb.cursor()
cur.execute("commit;")
def processMess(so,m):
global count
if type(m) != type({}):
return None
if m.has_key('turret') and m.has_key('user'):
so.usernames[m['turret']] = m['user']
if not m.has_key("op"):
return None
print m
if m["op"] == "MakeCall":
so.MakeCall(m['calling'],m['called'])
if m["op"] == "DTMF":
so.DTMF(m['connectionid'],m['charactersToSend'])
if m["op"] == "Query":
pass
HOST = '192.168.0.10'
PORT = 2555
so = phonesystem.PhoneSystem((HOST,PORT),group,server,mydb)
socopen = 1
last=time.time()
while socopen:
sin,sout,serr = select.select([so.connect,server.server],[],[so.connect,server.server],so.timeout()+0.1)
for income in sin:
if income==server.server:
mess = server.read()
if mess:
processMess(so,mess)
data=""
if income == so.connect:
try:
data = so.readmess()
except StandardError,e:
print e
socopen = 0
so.handleCsta(data)
if not sin and not sout and not serr or so.timeout()==0:
so.SendStatus()