~jonjfineman/callerID

076a39d8238a4b39a8f22a144f774817e4766722 — Jon Fineman 1 year, 8 months ago 8b2cdb4
misc
2 files changed, 30 insertions(+), 12 deletions(-)

M callBlock.py
M re_read_books.sh
M callBlock.py => callBlock.py +28 -11
@@ 11,6 11,10 @@ from launchMail import *



ser = None



for arg in sys.argv:
    print(arg)



@@ 101,6 105,15 @@ def sig_handler(signum, frame):



def sig_end(signum, frame):
    global ser

    ser.close()
    print("stopping\n")
    sys.exit(0)



def resetUSB(USBDevice):
    USBDEVFS_RESET= 21780



@@ 300,25 313,28 @@ def checkSilentList(number, name, book):
    for i in book:
        n = i.split(':')
        if number == n[0]:
            log.debug('checkSilentList for {}, found: {}, {}'.format(number, n[0], n[1]))
            print('checkSilentList for number {}, found: {}, {}'.format(number, n[0], n[1]))
            return([True, n[0], n[1]])
        
    # if number not found check name and see if it has * for number
    #for i in book:
    #    n = i.split(':')
    #    if name == n[1] and '*' == n[0]:
    #        return(True)
    for i in book:
        n = i.split(':')
        #print("book: ", i, n[1])
        if name == n[1] and '*' == n[0]:
            log.debug('checkSilentList for {}, found: {}, {}'.format(name, n[0], n[1]))
            print('checkSilentList for name {}, found: {}, {}'.format(name, n[0], n[1]))
            return([True, n[0], n[1]])

    log.debug('checkSilentList no match: {}, {}'.format(number, name))
        # check if regular expression (single quote as first char)
        elif n[1][0:1] == "'" and '*' == n[0]:
            n[1] = n[1][1:]
            #print('n: ', n[1], 'name: ', name)
            if re.search(n[1], name) != None:
                print('checkSilentList for re name {}, found: {}, {}'.format(name, n[0], n[1]))
                return([True, n[0], n[1]])

    print('checkSilentList no match: {}, {}'.format(number, name))
    return([False,'',''] )



def checkBlockList(number, name, book):
    for i in book:
        n = i.split(':')


@@ 343,7 359,7 @@ def checkBlockList(number, name, book):
        

def main(argv):
    global listSilent, listBlock, listBook
    global ser, listSilent, listBlock, listBook

    # open unknown number file



@@ 565,8 581,9 @@ def main(argv):
    
if __name__ == "__main__":
    
    # define signal
    # define signals
    signal.signal(signal.SIGUSR1, sig_handler)
    signal.signal(signal.SIGUSR2, sig_end)

    main(sys.argv)


M re_read_books.sh => re_read_books.sh +2 -1
@@ 1,3 1,4 @@
set -x

kill -SIGUSR1 $1
#kill -SIGUSR1 $1
pkill -SIGUSR1 -f 'callBlock.py'