summaryrefslogtreecommitdiffstats
path: root/abs/mv-core/ncid/ncid.py
blob: 7ffcefecd790f5145f2c2709be830d06f7d6fb8f (plain)
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
#!/usr/bin/python

import MySQLdb
import sys
import getopt
import socket
import os
db = MySQLdb.connect(host="127.0.0.1", user="mythtv", passwd="mythtv", db="mythconverg")
cdb = MySQLdb.connect(host="127.0.0.1", user="mythtv", passwd="mythtv", db="ncid")
#log to logger?



#log to db

def main(argv):

    DATE=sys.stdin.readline().strip()
    TIME=sys.stdin.readline().strip()
    NUMBER=sys.stdin.readline().strip()
    NAME=sys.stdin.readline().strip()


    #print "start of line"
    #print DATE
    #print TIME
    #print NUMBER
    #print NAME
    #print "$$$$$$$$$$$$$$$$$$"

#notify


    # create a cursor
    cursor = db.cursor()
    # execute SQL statement
    cursor.execute("SELECT DISTINCT(hostname) from settings where not hostname is NULL")
    result = cursor.fetchall()

    port1=str(5000)
    port2=str(5001)


    message = NAME + " :::" + "PHN"
    message2 = NUMBER + " :::" + "PH2"
    for row in result:
        os.system("/usr/bin/osdClient.pl  " + row[0] + "  " +  port1   + "   "+  "\"" +  message + "\""  + " 2>/dev/null  &" )
        os.system("/usr/bin/osdClient.pl  " + row[0] + "  " +  port2   + "   "+  "\"" +  message2 + "\""  + " 2>/dev/null  &" )
        #print ("/usr/bin/osdClient.pl  " + row[0] + "  " +  port2   + "   "+  "\"" +  message2 + "\""  + " 2>/dev/null  &" )


    ncursor=cdb.cursor()
    ncursor.execute ("""INSERT INTO cid (date,time,name,number)   VALUES     ('%s', '%s','%s','%s');"""         %(DATE,TIME,NAME,NUMBER )        )



if __name__ == "__main__":
    main(sys.argv[1:])