Ejemplo n.º 1
0
def get_a_sql_cur_forever(mylog, db_name=None):
    while True:
        if None == db_name:
            (_cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
        else:
            (_cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf",
                                               dbn=db_name)
        if None != _cur:
            break
        else:
            mylog.info(err)
            time.sleep(20)
    return _cur
Ejemplo n.º 2
0
def get_a_sql_cur_forever(db_name=None):
    global mylogger
    while True:
        if None == db_name:
            (_cur, conn_err) = wtclib.get_a_sql_cur("../conf/conf.conf")
        else:
            (_cur, conn_err) = wtclib.get_a_sql_cur("../conf/conf.conf",
                                                    db_name)
        if None != _cur:
            break
        else:
            mylogger.info(conn_err)
            time.sleep(20)
    return _cur, conn_err
Ejemplo n.º 3
0
def get_a_sql_cur_forever(mylog):
    while True:
        (_cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf", "hvpd3db2")
        if None != _cur:
            break
        else:
            mylog.info(err)
            time.sleep(20)
    return _cur
Ejemplo n.º 4
0
def get_a_sql_cur_forever(logger):
    while True:
        (_cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
        if None != _cur:
            break
        else:
            logger.info(err)
            time.sleep(20)
    return _cur
Ejemplo n.º 5
0
def get_mysql_cur():
    global mylogger
    while True:
        (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf", "hvpd3db2")
        if None != cur:
            break
        else:
            mylogger.info("can not connect to db and sleep 20")
            time.sleep(20)
    return cur
Ejemplo n.º 6
0
def get_a_sql_cur_forever():
    global mylogger
    while True:
        (_cur, conn_err) = wtclib.get_a_sql_cur("../conf/conf.conf",
                                                "hvpd3db2")
        if None != _cur:
            break
        else:
            mylogger.info(conn_err)
            time.sleep(20)
    return _cur, conn_err
Ejemplo n.º 7
0
def get_a_sql_cur_forever(mylog_i):
    while True:
        try:
            (_cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
            if None != _cur:
                break
            else:
                mylog_i.info(err)

        except Exception, e:
            mylog_i.info(str(e))
        time.sleep(20)
Ejemplo n.º 8
0
def msg_consumer(body):
    global cur, mylogger, msg_props, interval_sec, AIOUT_CH, msgsnd_ipc, msgrcv_ipc, AI_daybook_en, NEW_daybook_create

    _dic_info = json.loads(body)
    _cmos = _dic_info["cmos"]
    _sql_str = "select * from aisettingtablemem where cameraID='%s' and cmosID=%d" % (
        _dic_info["cam_id"], _cmos)
    try:
        if 0 == cur.execute(_sql_str):
            mylogger.debug("None= " + _sql_str)
            return
        _ai_setting = cur.fetchone()
        _sql_str = "select * from aiouttable where cameraID='%s' and cmosID=%d" % (
            _dic_info["cam_id"], _cmos)
        if 0 == cur.execute(_sql_str):
            _sql_str = "insert into aiouttable(cameraID,cmosID)values('%s',%d)" % (
                _dic_info["cam_id"], _cmos)
            cur.execute(_sql_str)
    except Exception, e:
        (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
        if None == cur:
            mylogger.error("can not connect to db and sleep 20")
            return
Ejemplo n.º 9
0
import time

import pika

import wtclib

if not os.path.isdir("../log/reret"):
    try:
        os.mkdir("../log/reret")
    except Exception, e:
        print str(e) + " in line: " + str(sys._getframe().f_lineno)
        os._exit()
mylogger = wtclib.create_logging("../log/reret/re2filter.log")
mylogger.info("start running")
while True:
    (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
    if None != cur:
        break
    else:
        mylogger.info("can not connect to db and sleep 20")
        time.sleep(20)
"""
cur.execute("insert into ReFilterTable(Spaceid, cameraID, cmosID)values('123456', '1315', 0)")
cur.execute("update ReFilterTable set PlateNumber1='wfbi' where Spaceid='123456'")
cur.execute("update ReFilterTable set PlateNumber1=NULL where Spaceid='123456'")
"""
"""
_pid = os.getpid()
try:
    cur.execute("insert into WatchdogTable(pid, runCMD,watchSeconds,renewTimet)values(%d, "
                "'python %s &', 300, %d)"%(_pid, __file__, (time.time())))
Ejemplo n.º 10
0
import time

import pika

import wtclib

if not os.path.isdir("../log/reret"):
    try:
        os.mkdir("../log/reret")
    except Exception, e:
        print str(e) + " in line: " + str(sys._getframe().f_lineno)
        os._exit()
mylogger = wtclib.create_logging("../log/reret/re2filter.log")
mylogger.info("start running")
while True:
    (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf", "hvpd3db2")
    if None != cur:
        break
    else:
        mylogger.info("can not connect to db and sleep 20")
        time.sleep(20)
"""
cur.execute("insert into ReFilterTable(Spaceid, cameraID, cmosID)values('123456', '1315', 0)")
cur.execute("update ReFilterTable set PlateNumber1='wfbi' where Spaceid='123456'")
cur.execute("update ReFilterTable set PlateNumber1=NULL where Spaceid='123456'")
"""
"""
_pid = os.getpid()
try:
    cur.execute("insert into WatchdogTable(pid, runCMD,watchSeconds,renewTimet)values(%d, "
                "'python %s &', 300, %d)"%(_pid, __file__, (time.time())))
Ejemplo n.º 11
0
import os, time,wtclib,socket

if __name__ == '__main__':
    while True:
        _cur, _conn = wtclib.get_a_sql_cur("../conf/conf.conf")
        if None == _cur:
            time.sleep(5)
        else:
            break
    print "DB connect OK"
    while True:
        print "********"
        try:
            a1 = _cur.execute("select * from OnlineHvpdStatusTableMem")
            _hvpds = _cur.fetchmany(a1)
            socket.setdefaulttimeout(1)
            try:
                for _hvps in _hvpds:
                    if None == _hvps[4]:
                        continue
                    wtclib.http_get_cgi_msg2device({"Lamp": "R:0,G:20,B:0"}, ip=_hvps[4],cgi_name="setting")
                    print "%s is Green"%_hvps[4]
            except Exception, e:
                print str(e)
            time.sleep(5)
            try:
                for _hvps in _hvpds:
                    if None == _hvps[4]:
                        continue
                    wtclib.http_get_cgi_msg2device({"Lamp": "R:0,G:0,B:20"}, ip=_hvps[4],cgi_name="setting")
                    print "%s is Blue" % _hvps[4]