예제 #1
0
def getlivelist(request, id):
    searchstr = request.REQUEST.get('findchannel', 'None')
    ID = id
    if ID == '4':
        if searchstr != 'None':
            sql = "SELECT channels.id,channels.display_name,channels.channel_name, servers.name,servers.ip_address,servers.host_name,streams.`name`,streams.uri FROM channels,servers,streams  WHERE channels.server_id = servers.id and channels.type = 'live' and channels.`status` <> 'DELETED' and  channels.id = streams.channel_id and streams.`status` = 'NORMAL' AND   concat(display_name, channel_name,uri) LIKE '%%%s%%' order by LENGTH (channels.id),channels.id;" % searchstr
            contents, counts = mysql_conn.mysql_handle(sql)
            http_status_input = stream_test.stream_test_input(contents)
            http_status_output = stream_test.stream_test_output(contents)
            return render_to_response('live/channelslist.html', locals())
        else:
            sql = "SELECT channels.id,channels.display_name,channels.channel_name, servers.name,servers.ip_address,servers.host_name,streams.`name`,streams.uri FROM channels,servers,streams  WHERE channels.server_id = servers.id and channels.type = 'live' and channels.`status` <> 'DELETED' and  channels.id = streams.channel_id and streams.`status` = 'NORMAL'  order by LENGTH (channels.id),channels.id;"
            contents, counts = mysql_conn.mysql_handle(sql)
            http_status_input = stream_test.stream_test_input(contents)
            http_status_output = stream_test.stream_test_output(contents)
            return render_to_response('live/channelslist.html', locals())
    else:
        if searchstr != 'None':
            sql = "SELECT channels.id,channels.display_name,channels.channel_name, servers.name,servers.ip_address,servers.host_name,streams.`name`,streams.uri FROM channels,servers,streams  WHERE channels.server_id = servers.id and channels.type = 'live' and channels.`status` <> 'DELETED' and servers.name='server%s' and channels.id = streams.channel_id and streams.`status` = 'NORMAL' AND   concat(display_name, channel_name,uri) LIKE '%%%s%%' order by servers.name,channels.id;" % (
                ID, searchstr)
            contents, counts = mysql_conn.mysql_handle(sql)
            http_status_input = stream_test.stream_test_input(contents)
            http_status_output = stream_test.stream_test_output(contents)
            return render_to_response('live/channelslist.html', locals())
        else:
            sql = "SELECT channels.id,channels.display_name,channels.channel_name, servers.name,servers.ip_address,servers.host_name,streams.`name`,streams.uri FROM channels,servers,streams  WHERE channels.server_id = servers.id and channels.type = 'live' and channels.`status` <> 'DELETED' and servers.name='server%s' and channels.id = streams.channel_id and streams.`status` = 'NORMAL'  order by servers.name,channels.id;" % ID
            contents, counts = mysql_conn.mysql_handle(sql)
            http_status_input = stream_test.stream_test_input(contents)
            http_status_output = stream_test.stream_test_output(contents)
            return render_to_response('live/channelslist.html', locals())
예제 #2
0
def getlivelist(request,id):
    searchstr = request.REQUEST.get('findchannel','None')
    ID = id
    if ID == '4':
        if searchstr != 'None':
            sql = "SELECT channels.id,channels.display_name,channels.channel_name, servers.name,servers.ip_address,servers.host_name,streams.`name`,streams.uri FROM channels,servers,streams  WHERE channels.server_id = servers.id and channels.type = 'live' and channels.`status` <> 'DELETED' and  channels.id = streams.channel_id and streams.`status` = 'NORMAL' AND   concat(display_name, channel_name,uri) LIKE '%%%s%%' order by LENGTH (channels.id),channels.id;"%searchstr
            contents,counts = mysql_conn.mysql_handle(sql)
            http_status_input = stream_test.stream_test_input(contents)
            http_status_output = stream_test.stream_test_output(contents)
            return render_to_response('live/channelslist.html',locals())
        else:
            sql = "SELECT channels.id,channels.display_name,channels.channel_name, servers.name,servers.ip_address,servers.host_name,streams.`name`,streams.uri FROM channels,servers,streams  WHERE channels.server_id = servers.id and channels.type = 'live' and channels.`status` <> 'DELETED' and  channels.id = streams.channel_id and streams.`status` = 'NORMAL'  order by LENGTH (channels.id),channels.id;"
            contents,counts = mysql_conn.mysql_handle(sql)
            http_status_input = stream_test.stream_test_input(contents)
            http_status_output = stream_test.stream_test_output(contents)
            return render_to_response('live/channelslist.html',locals())
    else:
        if searchstr != 'None':
            sql = "SELECT channels.id,channels.display_name,channels.channel_name, servers.name,servers.ip_address,servers.host_name,streams.`name`,streams.uri FROM channels,servers,streams  WHERE channels.server_id = servers.id and channels.type = 'live' and channels.`status` <> 'DELETED' and servers.name='server%s' and channels.id = streams.channel_id and streams.`status` = 'NORMAL' AND   concat(display_name, channel_name,uri) LIKE '%%%s%%' order by servers.name,channels.id;"%(ID,searchstr)
            contents,counts = mysql_conn.mysql_handle(sql)
            http_status_input = stream_test.stream_test_input(contents)
            http_status_output = stream_test.stream_test_output(contents)
            return render_to_response('live/channelslist.html',locals())
        else:
            sql = "SELECT channels.id,channels.display_name,channels.channel_name, servers.name,servers.ip_address,servers.host_name,streams.`name`,streams.uri FROM channels,servers,streams  WHERE channels.server_id = servers.id and channels.type = 'live' and channels.`status` <> 'DELETED' and servers.name='server%s' and channels.id = streams.channel_id and streams.`status` = 'NORMAL'  order by servers.name,channels.id;"%ID
            contents,counts = mysql_conn.mysql_handle(sql)
            http_status_input = stream_test.stream_test_input(contents)
            http_status_output = stream_test.stream_test_output(contents)
            return render_to_response('live/channelslist.html',locals())
예제 #3
0
def channeslencoder(requset, key):
    #显示全部
    if key == 'all':
        sql = "select channels.display_name,streams.uri from channels ,streams  where channels.id=streams.channel_id and streams.uri like '%channels%' and streams.status = 'NORMAL' order BY LENGTH(uri),uri"
        contents, counts = mysql_conn.mysql_handle(sql)
    #只显示发布的频道
    elif key == 'publish':
        sql = "select channels.display_name,streams.uri from channels ,streams  where channels.id=streams.channel_id and streams.uri like '%channels%' and streams.status = 'NORMAL' AND channels.status = 'ACTIVE' order BY LENGTH(uri),uri"
        contents, counts = mysql_conn.mysql_handle(sql)
    return render_to_response('live/channelencoder.html', locals())
예제 #4
0
def channeslencoder(requset,key):
    #显示全部
    if key == 'all':
        sql = "select channels.display_name,streams.uri from channels ,streams  where channels.id=streams.channel_id and streams.uri like '%channels%' and streams.status = 'NORMAL' order BY LENGTH(uri),uri"
        contents,counts = mysql_conn.mysql_handle(sql)
    #只显示发布的频道
    elif key == 'publish':
        sql = "select channels.display_name,streams.uri from channels ,streams  where channels.id=streams.channel_id and streams.uri like '%channels%' and streams.status = 'NORMAL' AND channels.status = 'ACTIVE' order BY LENGTH(uri),uri"
        contents,counts = mysql_conn.mysql_handle(sql)
    return render_to_response('live/channelencoder.html',locals())
예제 #5
0
def encoderstatus(request,key):
    if key == 'all':
        sql = "select streams.uri from channels ,streams  where channels.id=streams.channel_id and streams.uri like '%channels%' and streams.status = 'NORMAL' order BY LENGTH(uri),uri"
        uri,counts_sql = mysql_conn.mysql_handle(sql)
    elif key == 'publish':
         sql = "select streams.uri from channels ,streams  where channels.id=streams.channel_id and streams.uri like '%channels%' and streams.status = 'NORMAL' and channels.`status` = 'ACTIVE' order BY LENGTH(uri),uri"
         uri,counts_sql = mysql_conn.mysql_handle(sql)
    data={}
    for line in uri:
        #一个频道对应1路流
        if str(line).count('http') == 1:
            id1 = str(line).split('/')[2].split('.')[-1]
            k1 = 'encoder%s'%id1
            var1 = str(line).split('/')[5]
            if data.has_key(k1):
               tmplist1 = data[k1]
               tmplist1.append('%s'%var1)
               data[k1] = tmplist1
            else:
               data[k1]=[var1]
        #一个频道对应2路流:ex:http://172.16.110.19/channels/preview/1/flv:500k http://172.16.110.28/channels/preview/1/flv:500k
        elif str(line).count('http') == 2:
            t = str(line).split(' ')#利用空格切成两条记录
            for m in range(len(t)):
               id2 = str(t[m]).split('/')[2].split('.')[-1] #获取ip结尾
               k2 = 'encoder%s'%id2 #生成encoder名称当做字典的key
               var2 = str(t[m]).split('/')[5]
               if data.has_key(k2):
                  tmplist2 = data[k2] #获取存在的列表
                  tmplist2.append('%s'%var2) #往列表添加内容,不用担心数据重复,因为前端会处理的
                  data[k2] = tmplist2 #添加完列表,再存入原字典
               else:
                  data[k2]=[var2] #以encoder名称存入字典{'encoder':['1']}
    contents = {}
    #用于在页面生成有序的encodername
    for i in range(1,33):
          contents[i]=['encoder%s'%i,'172.16.110.%s'%i]
    defaultstatus = []
    #生成列表供页面使用
    for i in range(1,9):
        defaultstatus.append(i)
    counts = 0
    for k,v in data.items():
        counts += len(set(data[k]))
    use_counts = counts
    nouse_counts = 160 - int(counts) - 8 #encoder7 encoder16 已经废掉
    return render_to_response('live/encoderstatus.html',locals())
예제 #6
0
def enchajax(request):
    snum = request.POST.get('snum')
    hnum = request.POST.get('hnum')
    sql = "SELECT uri FROM streams WHERE channel_id = '%s'" % snum
    contents, counts = mysql_conn.mysql_handle(sql)
    for line in contents:
        s1 = str(line).find('110')  #提取服务器IP
        e1 = str(line).find('/channels')
        s2 = str(line).find('w/')  #提取编码器通道
        e2 = str(line).find('/f')
        snumf = str(line)[s1 + 4:e1]
        tnumf = str(line)[s2 + 2:e2]
    status = enhandle(snumf, tnumf, hnum)
    return {'status_code': status}
예제 #7
0
def enchajax(request):
    snum=request.POST.get('snum')
    hnum=request.POST.get('hnum')
    sql = "SELECT uri FROM streams WHERE channel_id = '%s'"%snum
    contents,counts = mysql_conn.mysql_handle(sql)
    for line in contents:
        s1 = str(line).find('110') #提取服务器IP
        e1 = str(line).find('/channels')
        s2 = str(line).find('w/') #提取编码器通道
        e2 = str(line).find('/f')
        snumf = str(line)[s1+4:e1]
        tnumf = str(line)[s2+2:e2]
    status = enhandle(snumf,tnumf,hnum)
    return {'status_code':status}