Exemplo n.º 1
0
def get_detail(start=0):
    try:
        conn = mysql.connector.connect(**config.mysql)
    except mysql.connector.Error as err:
        if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
            print("cann't connect to mysql server")
        if err.errno == errorcode.ER_BAD_DB_ERROR:
            print("database doesn't exist")
    cursor = conn.cursor()
    # cursor.execute("set NAMES latin1")

    try:
        if start == 0:
            cursor.execute("select * from logs")
        else:
            cursor.execute("select * from logs limit " + str(start) + ", 10000")
    except Exception as e:
        print(e)
    for i in cursor:
        ip = i[4]
        address = ip_info.get_ip_info(i[4])[-1]
        vid = i[5].split(".")[0]
        video_info = ip_info.get_vedio_info(vid)
        if video_info:
            video_name = video_info[0]
            video_type = video_info[1]
            video_png = video_info[2]
            detail = (vid, ip, str(address), video_name, video_type, video_png)
            yield detail
            # details.append(detail)
    cursor.close()
Exemplo n.º 2
0
def get_detail(start=0):
    try:
        conn = mysql.connector.connect(**config.mysql)
    except mysql.connector.Error as err:
        if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
            print("cann't connect to mysql server")
        if err.errno == errorcode.ER_BAD_DB_ERROR:
            print("database doesn't exist")
    cursor = conn.cursor()
    #cursor.execute("set NAMES latin1")

    try:
        if start == 0:
            cursor.execute("select * from logs")
        else:
            cursor.execute("select * from logs limit " + str(start) +
                           ", 10000")
    except Exception as e:
        print(e)
    for i in cursor:
        ip = i[4]
        address = ip_info.get_ip_info(i[4])[-1]
        vid = i[5].split('.')[0]
        video_info = ip_info.get_vedio_info(vid)
        if video_info:
            video_name = video_info[0]
            video_type = video_info[1]
            video_png = video_info[2]
            detail = (vid, ip, str(address), video_name, video_type, video_png)
            yield detail
            #details.append(detail)
    cursor.close()
Exemplo n.º 3
0
    def get_valid_top10(self, tops, top10_vid=None):
        if top10_vid is None:
            top10_vid = []

        res = []
        top10_count = 0
        f = open("vid.txt", 'w+')
        for i in tops:
            f.write(i[1] + '\t' + str(i[0]))
            f.write('\n')
            vid_name = ip_info.get_vedio_info(i[1])
            if not vid_name:
                continue
            if self.is_valid(vid_name[0]):
                top10_count += 1
                top10_vid.append(i[1])
                res.append((i, vid_name))
            ''' don't get video name
            top10_count += 1
            res.append((i[0], i[1]))
            '''
            if top10_count >= 10:
                break
        return res