Beispiel #1
0
def get_plate_rabbitmq_channel():
    global mylogger
    conf_dict = wtclib.get_user_config_ret_dict("../conf/conf.conf",
                                                "rabbitmq")

    if "platemq_server_addr" in conf_dict:
        _Plate_host = conf_dict["platemq_server_addr"]
    else:
        _Plate_host = wtclib.get_ip_addr1("eth0")
    if "platemq_server_port" in conf_dict:
        _Plate_port = int(conf_dict["platemq_server_port"])
    else:
        _Plate_port = 5672
    if "platemq_exchange" in conf_dict:
        Rabbitmq_Plate_exchange = conf_dict["platemq_exchange"]
    else:
        Rabbitmq_Plate_exchange = "plate"
    if "platemq_exchange_type" in conf_dict:
        _Plate_exchange_type = conf_dict["platemq_exchange_type"]
    else:
        _Plate_exchange_type = "direct"
    if "platemq_router_key" in conf_dict:
        Rabbitmq_Plate_router_key = conf_dict["platemq_router_key"]
    else:
        Rabbitmq_Plate_router_key = "plate queue"
    if "platemq_user_name" in conf_dict:
        _Plate_user_name = conf_dict["platemq_user_name"]
    else:
        _Plate_user_name = "wutao"
    if "platemq_passwd" in conf_dict:
        _Plate_passwd = conf_dict["platemq_passwd"]
    else:
        _Plate_passwd = "12345678"

    while True:
        try:
            credentials = pika.PlainCredentials("guest", "guest")
            conn_params = pika.ConnectionParameters(host="localhost",
                                                    virtual_host="/",
                                                    credentials=credentials,
                                                    heartbeat=60,
                                                    connection_attempts=5)
            conn_broker = pika.BlockingConnection(conn_params)
            break
        except Exception, e:
            mylogger.info(str(e))
            time.sleep(20)
Beispiel #2
0
def get_rabbitmq_channel():
    global mylogger
    conf_dict = wtclib.get_user_config_ret_dict("../conf/conf.conf",
                                                "rabbitmq")

    if "aioutmq_server_addr" in conf_dict:
        _mq_host = conf_dict["aioutmq_server_addr"]
    else:
        _mq_host = wtclib.get_ip_addr1("eth0")
    if "aioutmq_server_port" in conf_dict:
        _mq_port = int(conf_dict["aioutmq_server_port"])
    else:
        _mq_port = 5672
    if "aioutmq_exchange" in conf_dict:
        _mq_exchange = conf_dict["aioutmq_exchange"]
    else:
        _mq_exchange = "AiOut.tr"
    if "aioutmq_user_name" in conf_dict:
        _mq_user_name = conf_dict["aioutmq_user_name"]
    else:
        _mq_user_name = "user1"
    if "aioutmq_passwd" in conf_dict:
        _mq_passwd = conf_dict["aioutmq_passwd"]
    else:
        _mq_passwd = "9876543"
    if "aioutmq_vhost" in conf_dict:
        _mq_vhost = conf_dict["aioutmq_vhost"]
    else:
        _mq_vhost = "OutTrig"

    while True:
        try:
            credentials = pika.PlainCredentials(_mq_user_name, _mq_passwd)
            conn_params = pika.ConnectionParameters(host=_mq_host,
                                                    virtual_host=_mq_vhost,
                                                    credentials=credentials)
            conn_broker = pika.BlockingConnection(conn_params)

            break
        except Exception, e:
            mylogger.info(str(e))
            time.sleep(20)
Beispiel #3
0
            "insert into AiSoftwareVersion(SoftwareName, version)values('ai2filter','%s')"
            "ON DUPLICATE KEY UPDATE version='%s'" % (_version, _version))
    except Exception, e:
        mylogger.error(str(e) + time.asctime())
        os._exit()

    msg_props = pika.BasicProperties()
    msg_props.content_type = "text/plain"

    conf_dict = wtclib.get_user_config_ret_dict("../conf/conf.conf",
                                                "rabbitmq")

    if "aioutmq_server_addr" in conf_dict:
        _mq_host = conf_dict["aioutmq_server_addr"]
    else:
        _mq_host = wtclib.get_ip_addr1("eth0")
    if "aioutmq_server_port" in conf_dict:
        _mq_port = int(conf_dict["aioutmq_server_port"])
    else:
        _mq_port = 5672
    if "aioutmq_exchange" in conf_dict:
        _mq_exchange = conf_dict["aioutmq_exchange"]
    else:
        _mq_exchange = "AiOut.tr"
    if "aioutmq_user_name" in conf_dict:
        _mq_user_name = conf_dict["aioutmq_user_name"]
    else:
        _mq_user_name = "user1"
    if "aioutmq_passwd" in conf_dict:
        _mq_passwd = conf_dict["aioutmq_passwd"]
    else:
Beispiel #4
0
        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")
    userjpgMQ_reset_url = "http://%s:8803/?opt=reset&ver=2&name=zhang" % _ip
    try:
        res_data = urllib2.urlopen(userjpgMQ_reset_url)
        res = res_data.read()
        res_data.close()
    except Exception, e:
        mylog.debug(str(e))

    _timeSecOld = int(time.time())
    _mkdir = 0
    oldtime = time.localtime(_timeSecOld)
    daystr = "%04d%02d%02d/" % (oldtime.tm_year, oldtime.tm_mon,
                                oldtime.tm_mday)
    _top_day = _top_top + daystr
    if not os.path.isdir(_top_day):
Beispiel #5
0
                    os.rename("../../video", "../../video2")
                    os.symlink(_video_path, "../../video")

        if not os.path.exists("../../video"):
            os.mkdir("../../video")

    except Exception, e:
        mylogger.error(str(e))
        mylogger.error("new=%s,old=%s" % (_video_path, _link_to))
    if "smart_video" in conf_dict and 0 == conf_dict["smart_video"]:
        mylogger.info("smart video disable, end")
        os._exit(0)
    del conf_dict, _video_path, _link_to

    _CurServerID = get_serverID()
    ServerIP = wtclib.get_ip_addr1("eth0")
    cur = get_a_sql_cur_forever()

    _timeSecf = time.time()
    _timeSec = int(_timeSecf)
    try:
        cur.execute(
            "delete from video_rtsp2mp4_table where length(ServerID)=0")
        cur.execute(
            "update video_files_table set waiting_Timet=%d where ServerID='%s'"
            % (_timeSec, _CurServerID))
    except Exception, e:
        mylogger.error(str(e))

    _max_rtsp_client = check_max_rtsp_client_ch(cur)
    _day_dir_flag = 0