Beispiel #1
0
 def __init__(self, idnum):
     self.__id = idnum
     self.__timet = time.time()
     self.__downloadOKCnt = 0
     self.__downloadErrCnt = 0
     self.__logger = wtclib.create_logging('../log/airet/set_lamp%d.log' % idnum)
     threading.Thread.__init__(self)
Beispiel #2
0
 def __init__(self, idnum):
     self.__id = idnum
     self.__url_addr = []
     self.__file_name = []
     self.__pic_type = []
     self.__timet = time.time()
     self.__downloadOKCnt = 0
     self.__downloadErrCnt = 0
     self.__logger = wtclib.create_logging(
         '../log/downfilelog/thread%d.log' % idnum)
     threading.Thread.__init__(self)
Beispiel #3
0
    def __init__(self, idnum):

        self.__logger = wtclib.create_logging('../log/ai_shell/sync.log')
        threading.Thread.__init__(self)
Beispiel #4
0
import json
import os
import socket
import sys
import time
import urllib
import urllib2

import MySQLdb

import wtclib

mylogger = wtclib.create_logging("NewDeviceSetup.log")
mylogger.info("start running")


def ucmq_get_msg(ucmq_url):
    global mylogger
    while True:
        while True:
            try:
                res_data = urllib2.urlopen(ucmq_url)
                break
            except urllib2.URLError, e:
                print str(e) + " in line: " + str(sys._getframe().f_lineno)
                mylogger.info(str(e))
                time.sleep(20)
                continue
        res = res_data.read()
        mq_str = res.split('\n')
        #print mq_str[0]
Beispiel #5
0
        if None != _cur:
            break
        else:
            mylogger.info(err)
            time.sleep(20)
    return _cur


if __name__ == '__main__':
    if not os.path.isdir("../log/auto_reboot"):
        try:
            os.mkdir("../log/auto_reboot")
        except Exception, e:
            print str(e)
            os._exit()
    mylogger = wtclib.create_logging("../log/auto_reboot/auto_reboot.log")
    mylogger.info("start running")
    os.remove("hvpd.db")
    os.remove("rebootlog.db")
    sqlite_cur, hvpd_conn = get_sqlite_cur("hvpd.db")
    reboot_Log_cur, log_conn = get_sqlite_cur("rebootlog.db")
    _sql = "create table if not exists hvpdOnline(" \
           "cameraID char(24)," \
           "cmosID int," \
           "ip char(20)," \
           "reboot_timet int," \
           "reboot_time datetime," \
           "primary key(cameraID, cmosID)" \
           ");"
    sqlite_cur.execute(_sql)
Beispiel #6
0
import json
import os
import sys
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()
Beispiel #7
0
                mylogger.error(str(e))
                mylogger.error(_sql)
    except Exception, e:
        mylogger.error(str(e))
    return


if __name__ == '__main__':
    global mylogger
    if not os.path.isdir("../log/airet"):
        try:
            os.mkdir("../log/airet")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylogger = wtclib.create_logging("../log/airet/ai2getyuv.log")
    mylogger.info("start running")
    cur = get_a_sql_cur_forever(mylogger)
    ServerID = wtclib.get_serverID()
    #sqlite3_cur, sqlite3_conn = wtclib.get_a_sqlite3_cur_forever(mylogger, "/tmp/softdog.db")
    try:
        cur.execute(
            "insert into WatchdogTable(pid, runCMD,watchSeconds,renewTimet,ServerID)values(%d, "
            "'python %s &', 35, %d,'%s')" %
            (os.getpid(), __file__, time.time(), ServerID))
        _dic1 = wtclib.get_user_config_ret_dict("aisoftversion.ini", "version")
        if "ai2getyuv" in _dic1:
            _version = _dic1["ai2getyuv"]
        else:
            stat = os.stat(__file__)
            _version = datetime.date.fromtimestamp(stat.st_mtime).isoformat()
Beispiel #8
0
import os
import signal
import time
#import sqlite3
import psutil

import wtclib

if __name__ == '__main__':
    mylog = wtclib.create_logging("../log/wdt2.log")
    #print os.getcwd()
    #for proc in psutil.process_iter():
    #    print proc.name()
    while True:
        (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
        if None != cur:
            break
        else:
            mylog.info("can not connect to db and sleep 20")
            time.sleep(20)

    _AI_delay = 300
    _consumer_delay = 300
    _vlpr_delay = 300
    _bind_delay = 300
    while True:
        _timeSec = int(time.time())
        _AI_in_proc = 0
        _consumer_in_proc = 0
        _vlpr_in_proc = 0
        _bind_in_proc = 0
Beispiel #9
0
            cur.execute(_sql_str)
            mylog.info("bays using %d"%_using)
            return 0
        return -2
    except Exception,e:
        mylog.error(str(e))
        return -1

if __name__ == '__main__':
    if not os.path.isdir("../log/configfiles/"):
        try:
            os.mkdir("../log/configfiles/")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylog = wtclib.create_logging("../log/configfiles/configfiles.log")
    mylog.info("start")

    url_ret, userjpgMQ_status_url = wtclib.get_ucmq_status_url("userjpg")
    if 0 == url_ret:
        userjpgMQ_status_url = "http://127.0.0.1:8803/?opt=status_json&ver=2&name=userjpg"
    url_ret, userjpgMQ_reset_url = wtclib.get_ucmq_reset_url("userjpg")
    if 0 == url_ret:
        userjpgMQ_reset_url = "http://127.0.0.1:8803/?opt=reset&ver=2&name=userjpg"
    url_ret, downloadMQ_status_url = wtclib.get_ucmq_status_url("downloadmq")
    if 0 == url_ret:
        downloadMQ_status_url = "http://127.0.0.1:8803/?opt=status_json&ver=2&name=downloadmq"
    url_ret, downloadMQ_reset_url = wtclib.get_ucmq_reset_url("downloadmq")
    if 0 == url_ret:
        downloadMQ_reset_url = "http://127.0.0.1:8803/?opt=reset&ver=2&name=downloadmq"
Beispiel #10
0
    try:
        cur.execute("TRUNCATE TABLE OnlineHvpdStatusTableMem")
    except Exception, e:
        print str(e) + " in line: " + str(sys._getframe().f_lineno)


if __name__ == '__main__':

    if not os.path.isdir("../log/downfilelog"):
        try:
            os.mkdir("../log/downfilelog")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    #mylogger = create_logging("downfilelog/Mthread.log")
    mylogger = wtclib.create_logging("../log/downfilelog/Mthread.log")
    mylogger.info("start running")
    if not os.path.isdir('../../ai/jpg/'):
        try:
            os.mkdir('../../ai/jpg/')
        except Exception, e:
            mylogger.error(str(e))
            os._exit(2)
    if not os.path.isdir(DIRECTION_SAVE_FILES):
        try:
            os.mkdir(DIRECTION_SAVE_FILES)
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            mylogger.error(str(e))
            os._exit()
Beispiel #11
0
        except Exception, e:
            wdtlogger.error(str(e))
            _cur = get_a_sql_cur_forever()
        time.sleep(2)


if __name__ == '__main__':
    #shutil.move("17124360930_161626.mp4", "../123.mp4")
    if not os.path.isdir("../log/rtsp2mp4m"):
        try:
            os.mkdir("../log/rtsp2mp4m")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()

    mylogger = wtclib.create_logging("../log/rtsp2mp4m/m.log")
    wdtlogger = wtclib.create_logging("../log/rtsp2mp4m/wdt.log")

    mylogger.info("start running")
    if not os.path.isdir("/tmp/rtsp2mp4"):
        try:
            os.mkdir("/tmp/rtsp2mp4")
        except Exception, e:
            mylogger.error(str(e))
            os._exit(1)
    _Max_video_sec = 900
    conf_dict = wtclib.get_user_config_ret_dict("../conf/conf.conf",
                                                "file_save")
    if "video_length_sec" in conf_dict:
        _Max_video_sec = int(conf_dict["video_length_sec"])
    if _Max_video_sec > 1800 or _Max_video_sec < 30:
Beispiel #12
0
    def __init__(self, idnum):

        self.__logger = wtclib.create_logging('../log/re_shell/result.log')
        threading.Thread.__init__(self)
Beispiel #13
0
def python_cmd(cmd):
    str1 = "@%d" % (os.getpid())
    print cmd + str1
    os.system(cmd)
    #os.system("pause")
    time.sleep(0.5)


if __name__ == '__main__':
    if not os.path.isdir("../log/re_shell"):
        try:
            os.mkdir("../log/re_shell")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylogger = wtclib.create_logging("../log/re_shell/re_shell.log")
    mylogger.info("start running")
    _dic1 = wtclib.get_user_config_ret_dict("../conf/conf.conf", "file_save")
    if "backup_ai_jpg" in _dic1:
        Backup_ai_jpg = _dic1["backup_ai_jpg"]
    else:
        Backup_ai_jpg = '0'
    if "backup_re_jpg" in _dic1:
        Backup_re_jpg = _dic1["backup_re_jpg"]
    else:
        Backup_re_jpg = '0'
    del _dic1
    if '1' == Backup_re_jpg:
        if not os.path.isdir("../../re/yuv"):
            try:
                os.mkdir("../../re/yuv")
Beispiel #14
0
import json
import os
import socket
import sys
import time
import urllib
import urllib2

import wtclib

if __name__ == '__main__':
    mylog = wtclib.create_logging("../log/h264.log")
    (val, _ucmq_url) = wtclib.get_ucmq_url("h264mq")
    if 0 == val:
        mylog.info("can not get a ucmq url" + _ucmq_url)
        os._exit()
    s = os.getcwd()
    mylog.info("H264 start")

    _top_top = s[:s[0:s.rfind('/')].rfind('/')] + "/video/"
    if not os.path.isdir(_top_top):
        os.mkdir(_top_top)

    fileCnt = 0
    socket.setdefaulttimeout(10)
    _timeSecOld = int(time.time()) - 7200
    while True:
        _timeSec = int(time.time())
        _gmtime = time.localtime(_timeSec)
        if _timeSec - _timeSecOld > 3600:
            _timeSecOld = _timeSec
Beispiel #15
0
        if None != _cur:
            break
        else:
            mylogger.info(conn_err)
            time.sleep(20)
    return _cur, conn_err


if __name__ == '__main__':
    if not os.path.isdir("../log/rmfilelog"):
        try:
            os.mkdir("../log/rmfilelog")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylogger = wtclib.create_logging("../log/rmfilelog/rmfile.log")
    mylogger.info("start running")

    conf_dict = wtclib.get_user_config_ret_dict("../conf/conf.conf",
                                                "file_save")
    if "root_dir" in conf_dict:
        root_dir = conf_dict["root_dir"]
    else:
        #s = os.getcwd()
        #root_dir = s[:s[0:s.rfind('/')].rfind('/')]
        #del s
        root_dir = "../.."
    if "fullsize_pic_save_days" in conf_dict and conf_dict[
            "fullsize_pic_save_days"].isdigit():
        fullsize_days = int(conf_dict["fullsize_pic_save_days"])
    else:
Beispiel #16
0
import json
import os
import socket
import sys
import time
import urllib
import urllib2

import wtclib

if __name__ == '__main__':
    mylog = wtclib.create_logging("../log/origjpg.log")
    (val, _ucmq_url) = wtclib.get_ucmq_url("userjpg")
    if 0 == val:
        mylog.info("can not get a ucmq url" + _ucmq_url)
        os._exit()
    s = os.getcwd()
    mylog.info("origjpg start")

    _top_top = s[:s[0:s.rfind('/')].rfind('/')] + "/orig/"
    if not os.path.isdir(_top_top):
        os.mkdir(_top_top)

    fileCnt = 0
    socket.setdefaulttimeout(10)
    _timeSecOld = int(time.time()) - 7200
    while True:
        _timeSec = int(time.time())
        if _timeSec - _timeSecOld > 3600:
            _timeSecOld = _timeSec
            oldtime = time.localtime()
Beispiel #17
0
 def __init__(self, idnum):
     self.__logger = wtclib.create_logging('../log/downfilelog/mono.log')
     threading.Thread.__init__(self)
Beispiel #18
0
import json
import os
import socket
import sys
import time
import urllib
import urllib2

import wtclib

if __name__ == '__main__':
    mylog = wtclib.create_logging("../log/userjpg.log")
    (val, _ucmq_url) = wtclib.get_ucmq_url("userjpg")
    if 0 == val:
        mylog.info("can not get a ucmq url" + _ucmq_url)
        os._exit()
    s = os.getcwd()
    mylog.info("userjpg start")
    _top_top = s[:s[0:s.rfind('/')].rfind('/')]
    if not os.path.isdir("/tmp/userjpg"):
        os.mkdir("/tmp/userjpg")
    _top_top = "/tmp"

    socket.setdefaulttimeout(10)
    while True:
        try:
            res_data = urllib2.urlopen(_ucmq_url)
            res = res_data.read()
            res_data.close()
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
Beispiel #19
0
        dirs = cf.get("file_save", "root_dir")
        return dirs
    except Exception, e:
        #mylog.error(str(e) + ' get file_save')
        return None


if __name__ == '__main__':

    if not os.path.isdir("../log/leddisplog"):
        try:
            os.mkdir("../log/leddisplog")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylog = wtclib.create_logging("../log/leddisplog/ledplayer.log")
    mylog.info("start")

    cur = get_a_sql_cur_forever(mylog)
    create_qld_db(cur)
    #mylog.warning(cur.connection)
    #mylog.warning(cur.messages)
    if None == cur:
        mylog.error("connect to db fail")
        os._exit()
    thread = led_displayer_udp_server()
    thread.start()
    """"""
    #time.sleep(25)
    thread_idles = THREAD_NUM
Beispiel #20
0
import json
import os
import socket
import sys
import time
import urllib
import urllib2

import wtclib

if __name__ == '__main__':
    mylog = wtclib.create_logging("../log/zhang.log")
    (val, _ucmq_url) = wtclib.get_ucmq_url("zhang")
    if 0 == val:
        mylog.info("can not get a ucmq url" + _ucmq_url)
        os._exit()
    s = os.getcwd()
    mylog.info("zhang start")

    _top_top = s[:s[0:s.rfind('/')].rfind('/')] + "/zhang/"
    if not os.path.isdir(_top_top):
        os.mkdir(_top_top)

    fileCnt = 0
    socket.setdefaulttimeout(10)

    conf_dict = wtclib.get_user_config_ret_dict("../conf/conf.conf", "ucmq")
    if "server_addr" in conf_dict:
        _ip = conf_dict["server_addr"]
    else:
        _ip = wtclib.get_ip_addr1("eth0")
Beispiel #21
0
 def __init__(self):
     self.__logger = wtclib.create_logging(
         '../log/leddisplog/udpserver.log')
     threading.Thread.__init__(self)
Beispiel #22
0
                gQueue_ret.put(json.dumps(_recv_dict))

                self.__logger.debug("child end  id=" + str(self.__id) +
                                    " time=" + str(time.time()) + " use %f" %
                                    (time.time() - _timet_in))


if __name__ == '__main__':
    if not os.path.isdir("../log/airet"):
        try:
            os.mkdir("../log/airet")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    #mylogger = create_logging("downfilelog/Mthread.log")
    mylogger = wtclib.create_logging("../log/airet/Mlamp.log")
    mylogger.info("start running")
    gThread_using_flag = []

    for i in range(THREAD_NUM):
        flag = 1
        gThread_using_flag.append(flag)
        thread = setting_cgi_lamp(i)
        thread.start()
    cur = get_mysql_cur()
    if None == cur:
        mylogger.error("config fail with db")
        os._exit()

    _timet_slow = time.time()
    while True:
Beispiel #23
0
    def __init__(self, num):
        self.__id = num
        self.__logger = wtclib.create_logging(
            '../log/leddisplog/tcpclient%d.log' % num)

        threading.Thread.__init__(self)
Beispiel #24
0
        if None != _cur:
            break
        else:
            mylog.info(err)
            time.sleep(20)
    return _cur


if __name__ == '__main__':
    if not os.path.isdir("../log/airet"):
        try:
            os.mkdir("../log/airet")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylogger = wtclib.create_logging("../log/airet/yuvfilter.log")
    mylogger.info("start running")
    cur = get_a_sql_cur_forever(mylogger)

    conf_dict = wtclib.get_user_config_ret_dict("../conf/conf.conf", "plate")
    _haveCar_delay = 30
    if "havecar_delay" in conf_dict:
        _haveCar_delay = int(conf_dict["havecar_delay"])
    if _haveCar_delay < 5 or _haveCar_delay > 600:
        _haveCar_delay = 30

    channel = get_rabbitmq_channel()

    # msg = sys.argv[1]
    msg = "hello" + str(time.localtime())
    msg_props = pika.BasicProperties()
Beispiel #25
0
def python_cmd(cmd):
    str1 = "@%d" % (os.getpid())
    print cmd + str1
    os.system(cmd)
    #os.system("pause")
    time.sleep(0.5)


if __name__ == '__main__':
    if not os.path.isdir("../log/ai_shell"):
        try:
            os.mkdir("../log/ai_shell")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylogger = wtclib.create_logging("../log/ai_shell/ai_test.log")
    mylogger.info("start running")

    AI_daybook_en = 1

    cur = get_a_sql_cur_forever(mylogger)
    try:
        _pipe = os.popen("ps aux|grep AI")
        _pipe_data = _pipe.read()
        _pipe.close()
        print _pipe_data
        _retV = _pipe_data.strip("\n").split('\n')
        print _retV[0]
        if len(_retV) > 2:
            os.system("killall AI")
            print "kill AI"
Beispiel #26
0
                                        0x8915, \
                                        struct.pack('256s', ifname[:15]))[20:24])
    except Exception, e:
        mylogger.error(str(e))
        return None
    return addr


if __name__ == '__main__':
    global mylogger
    if not os.path.isdir("../log/udplog"):
        try:
            os.mkdir("../log/udplog")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit(0)

    mylogger = wtclib.create_logging("../log/udplog/udpbroad0.log")
    mylogger.info("start running")
    addr = get_ip_addr("eth0")
    if None == addr:
        mylogger.error("eth0 addr is None")
        os._exit(0)
    cnt = 10
    while True:

        Udp_broadcast(addr, UDP_BROADCAST_PORT)
        time.sleep(3)

        mylogger.error("udp broadcast is running, and nerver here")
Beispiel #27
0
import time


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


if __name__ == '__main__':
    mylogger = wtclib.create_logging("../log/vm.log")
    cur = get_a_sql_cur_forever(mylogger)
    try:

        _sql_str = "select * from aisettingtable_camera where cameraID='1804430018' "
        cur.execute(_sql_str)
        _src = cur.fetchone()

        for i in range(1, 1000):
            _sql_str = "insert into aisettingtable_camera(cameraID,user_manual_parking_line," \
                       "manual_parking_line1LTx,manual_parking_line1LTy,manual_parking_line1RTx,manual_parking_line1RTy," \
                       "manual_parking_line1LBx,manual_parking_line1LBy,manual_parking_line1RBx,manual_parking_line1RBy," \
                       "manual_parking_line2LTx,manual_parking_line2LTy,manual_parking_line2RTx,manual_parking_line2RTy," \
                       "manual_parking_line2LBx,manual_parking_line2LBy,manual_parking_line2RBx,manual_parking_line2RBy," \
                       "manual_parking_line3LTx,manual_parking_line3LTy,manual_parking_line3RTx,manual_parking_line3RTy," \
                       "manual_parking_line3LBx,manual_parking_line3LBy,manual_parking_line3RBx,manual_parking_line3RBy" \