Example #1
0
def channels():
    message = """select live_channel.chid,tvs_channel.chname,live_server.live_ip,live_url.live_path,live_status.sname """
    message += """from tvs_channel,live_channel,live_server,live_url,live_status where tvs_channel.chid=live_channel.chid and """
    message += """live_status.statusid=live_channel.statusid and live_url.live_urlid=live_channel.live_urlid and live_url.serverid = live_server.serverid """
    message += """and live_url.status=0 order by live_channel.chid """

    conn = my_sql.connect()
    cursor = conn.cursor()
    cursor.execute(message)
    result = cursor.fetchall()
    conn.close()
    
    headers = ["频道名称", "直播地址", "直播路径", "发布状态"]
    print(yate.start_response())
    print(yate.include_header("JSB living system"))
    print(yate.start_form("edit.py"))
    print(yate.start_table(tb_width="80%", tb_border="1px solid"))
    print(yate.tb_caption("已发布频道"))
    print(yate.tb_header(headers))

    for array in result:
        print(yate.tb_data(array[1:]))
    print(yate.end_table())
    print(yate.end_form())
    print(yate.include_footer({"Home": "/index.html"}))
Example #2
0
def editUrl():

    print(Osyate.start_response())
    '''
    #Print table in browser
    '''
    conn = connect('set_os.ini')
    cur = conn.cursor()
    cur.execute('''select u_hurl.spid,u_hurl.id,u_sp.name,u_hurl.ip,u_hurl.port 
    from u_hurl,u_sp where u_sp.id=u_hurl.spid and u_hurl.statusid <> 2''')
    
    results = cur.fetchall()
    conn.close()
    title='地址管理'
    
    jsurl = '../js/edirUrl.js'
    print(Osyate.include_header(title,jsurl))
    print(Osyate.start_div(divId='editOsname', site='left'))
    print(Osyate.start_table(classname='table', width='100%', site='left'))
    print(Osyate.start_tr())
    tagname=['项目名称','地址','存储位置','端口号']
    for item in tagname:
        print(Osyate.table_th(classname='bg_tr', site='left', ms=item))
    print(Osyate.end_tr())
    path = 'null'
    if results != ():
        for row in results:   
            mixid = ''.join([str(row[0]),'&',str(row[1])])
            #print 'mixid',mixid
            print(Osyate.url_t2(mixid,row[2],row[3],path,row[4]))
    print(Osyate.end_table())
    print(Osyate.url_t3('deal_editUrl.py'))   
    print(Osyate.include_footer())
Example #3
0
def deal_editMac():
    osname = ""
    osid = ""
    # print(Osyate.start_response())
    form_data = cgi.FieldStorage(encoding="gbk")
    conn = connect("set_os.ini")
    cur = conn.cursor()

    mid = form_data.getvalue("spid", None)
    mac1 = form_data.getvalue("mac1", None)
    mac2 = form_data.getvalue("mac2", None)
    submitinfo = form_data.getvalue("submit")
    deltinfo = "删除"
    updinfo = "修改"
    if (mid and mac1 and mac2) is not None:
        spid = int(mid.split("&").pop(0))
        devid = int(mid.split("&").pop(1))
        deltMes = """delete from u_devices where id=%s""" % devid
        updMes = """update u_devices set mac_l='%s', mac_u= '%s' where id=%s""" % (mac1, mac2, devid)

        if submitinfo == deltinfo:
            print("deddd")
            cur.execute(deltMes)
            conn.commit()
        if submitinfo == updinfo:
            cur.execute(updMes)
            conn.commit()
    editMac()
Example #4
0
def channels_offline(channel_offline=True):
    message = ("""SELECT ulv_genchannels.channel_id,
    tvs_channel.chname, 
    ulv_genaddress.gen_address, 
    ulv_status.des
    FROM ulv_genchannels
    NATURAL JOIN tvs_channel, ulv_genaddress, ulv_status
    WHERE ulv_genchannels.channel_id = tvs_channel.chid 
    AND tvs_channel.chid = ulv_genaddress.channel_id 
    AND ulv_status.status_id=1 order by ulv_genchannels.sort_id, ulv_genchannels.channel_id""")

    conn = my_sql.connect()
    cursor = conn.cursor()
    cursor.execute(message)
    result = cursor.fetchall()
    conn.close()
    
    headers = ["频道名称", "频道编号", "直播路径", "发布状态"]
    print(yate.start_response())
    if channel_offline:
        print(yate.include_header("频道下线"))
    else:
        print(yate.include_header("已发布频道"))
    print(yate.start_form("ft_channels_offline.py"))
    print(yate.start_table(tb_width="100%", tb_border="1px solid"))
    print(yate.tb_header(headers))
    
    for array in result:
        print(yate.do_table(array, channel_offline))

    print(yate.end_table())
    if channel_offline==True:
        print(yate.end_form("确定"))
Example #5
0
def deal_editUrl():
         conn = connect('set_os.ini')
         cur = conn.cursor()
         form_data = cgi.FieldStorage(encoding='gbk')
         mixid = form_data.getvalue('spid',None)
         ip = form_data.getvalue('ip',None)
         port = form_data.getvalue('port',None)
         submitValue = form_data.getvalue('submit',None)
         editinfo = '修改'
         deltinfo = '删除'
         
         if (mixid and ip and port and submitValue) is not None:                  
                  spid = int(mixid.split('&').pop(0))
                  hurlid = int(mixid.split('&').pop(1))
                  delMes = '''delete from u_hurl  where id=%s''' % hurlid
                  updMes = '''update u_hurl set ip='%s',port=%s where id=%s''' % (ip,port,hurlid)
                   
                  
                  if submitValue == editinfo:
                           cur.execute(updMes)
                           conn.commit()
                     
                  if submitValue == deltinfo:
                           cur.execute(delMes)
                           conn.commit()    
         editUrl()
Example #6
0
def deal_editOsname():
    osname = ""
    osid = ""

    """
    Get data from cgi
    """
    form_data = cgi.FieldStorage()
    # print form_data
    if "osname" in form_data and "osid" in form_data:
        osname = form_data["osname"].value
        osid = form_data["osid"].value

    conn = connect()
    cursor = conn.cursor()

    """
    Update db if u_sp's data changed!
    """
    if osname != "" and osid != "":
        ms = """update u_sp set name="%s" where id=%s""" % (osname, osid)
        # print ms
        cursor.execute(ms)
        conn.commit()
    editOsname()
Example #7
0
def MacAdd():
    print(Osyate.start_response())
    print(Osyate.addOms())
    conn = connect('set_os.ini')
    cursor = conn.cursor()    
    cursor.execute("""select id,name from u_sp""")
    result = cursor.fetchall()
    conn.close()  
    print(Osyate.start_select_mac('deal_addMac.py'))
    for row in result:
        print(Osyate.sub_option({row[0]:row[1]}))
    print(Osyate.sub_pubend_next())    
    print(Osyate.include_footer())    
Example #8
0
def get_response():
    form_data = cgi.FieldStorage(encoding='gbk')
    print(Osyate.start_response())
    spid = form_data.getvalue('osid',None)
    #print(form_data)
    if spid != None:
        conn = connect('set_os.ini')
        cursor = conn.cursor()
        msg = '''update u_hurl set statusid=3 where spid=%s''' % spid
        cursor.execute(msg)
        conn.commit()
        conn.close()
        print('YOU HAVE DONE IT SUCCESS!')
def genaddress_publish():
    # channel_list
    allchannel = {}
    allcatagory = {}

    conn = my_sql.connect()
    cur = conn.cursor()

    cur.execute(
        """select live_url.chid,live_url.live_urlid,tvs_channel.chname from tvs_channel,
    live_url where tvs_channel.status=0 and live_url.status=0 and live_url.chid=tvs_channel.chid order by tvs_channel.chid"""
    )
    dic = cur.fetchall()
    apd = ""
    for each in dic:
        apd = " ".join([str(each[0]), str(each[1])])
        allchannel[apd] = each[2].encode("utf-8")
        apd = ""
        # print allchannel

        # select catagory id
        cur.execute("""select sort_id,sort_name from live_sort """)
        catagorydic = cur.fetchall()
        conn.close()

    for each in catagorydic:
        allcatagory[each[0]] = each[1].encode("utf-8")

    print(yate.start_response())
    print(yate.render_publish(urls="edit.py"))
    # print(yate.start_form("edit.py"))

    print(yate.select("mix"))
    print(yate.select_list_new(allchannel))
    print(yate.end_select())

    print(yate.select("sortid"))
    print(yate.select_list_new(allcatagory))
    print(yate.end_select())

    """
    print(yate.select('logo'))
    print(yate.select_list_n(alllogoname))
    print(yate.end_select())
    """
    # print(yate.end_form("add"))
    print(yate.submit())
Example #10
0
def get_response():
    spid = ""
    ip = ""
    port = ""
    # print(Osyate.start_response())
    form_data = cgi.FieldStorage()
    if form_data:
        spid = form_data.getvalue("spid")
        ip = form_data.getvalue("ip")
        port = form_data.getvalue("port")

    conn = connect("set_os.ini")
    cursor = conn.cursor()
    if spid is not None and spid != "" and spid is not None and spid != "" and ip is not None and ip != "":
        cursor.execute("""insert into u_hurl (spid,ip,port,statusid) values(%s,'%s',%s,%s)""" % (spid, ip, port, 1))
        conn.commit()
        conn.close()
    editUrl()
Example #11
0
def EpgUrlAdd():
    print(Osyate.addOms())
    
    conn = connect('set_os.ini')
    cursor = conn.cursor()    
    cursor.execute("""SELECT
    sp.id,sp.name
    from u_sp as sp
    where 
    sp.id not in 
    (SELECT u_hurl.spid from u_hurl where u_hurl.statusid =2) 
    or sp.id not in (SELECT u_hurl.spid from u_hurl)""")
    result = cursor.fetchall()
    conn.close()
    print(Osyate.start_select_Epg('deal_addEpgUrl.py'))
    for row in result:    
        print(Osyate.sub_option({row[0]:row[1]}))        
    print(Osyate.sub_pubend())    
    print(Osyate.include_footer())  
Example #12
0
def channels_publish():
    cmdmsg = ("""SELECT tvs_channel.chid, tvs_channel.chname
    FROM tvs_channel
    NATURAL JOIN ulv_genaddress
    WHERE tvs_channel.`status` <> 1 AND tvs_channel.chid = ulv_genaddress.channel_id
    order by tvs_channel.chid""")
    
    conn = my_sql.connect()
    cur = conn.cursor()
    cur.execute(cmdmsg)
    result = cur.fetchall()
    
    msg = ("""select sort_id,sort_name from ulv_sort""")
    cur.execute(msg)
    sortinfo = cur.fetchall()
    conn.close()

    print(yate.start_response())
    print(yate.include_header("上线频道"))
    print("<p ><b>通过下面的复选框选择要上线的频道</b></p>")    
    print(yate.start_form("ft_channels_publish.py"))
    print(yate.start_table(tb_width="50%", tb_border="1px solid"))
    print(yate.start_row())
    print("<center>")   
    print(yate.select("channel_id"))
    print(yate.select_option(result))
    print(yate.end_select())  
    print('</center>')
    print(yate.end_row())
    
    print(yate.start_row())
    print("<center>")
    print(yate.select("sort_id"))
    print(yate.select_option(sortinfo))
    print(yate.end_select()) 
    print('</center>')
    print(yate.end_row())    
    
    print(yate.start_row())
    print(yate.end_form("确定"))
    print(yate.end_row())
    print(yate.end_table())
Example #13
0
def editOsname(title,links,msg=None):    
        
    '''
    Substitute the template
    '''
    print(Osyate.start_response())
    conn = connect('set_os.ini')
    cursor = conn.cursor()
    if msg == None:
        msg= '''select name,id from u_sp'''    
    cursor.execute(msg)
    results = cursor.fetchall()
    conn.close()
    print(Osyate.osn_t1(title))
    
    if results != ():
        for row in results:
            print(Osyate.osn_t2(row[0],row[1],row[2]))
    print(Osyate.osn_t3(links))   
    print(Osyate.include_footer())   
Example #14
0
def get_channelInfo_from_store(spid):
    m1 = ("""SELECT ulv_opchannels.chid,
    tvs_channel.chname,
    ulv_dns.dns_name,
    ulv_genaddress.gen_address,    
    ulv_genchannels.sort_id
    from ulv_dns,ulv_genaddress,ulv_opchannels,ulv_genchannels,tvs_channel
    where ulv_opchannels.sp_id=%d 
    and ulv_dns.sp_id =%d 
    and ulv_genaddress.channel_id = ulv_opchannels.chid
    and tvs_channel.chid = ulv_opchannels.chid
    and ulv_genchannels.channel_id = ulv_opchannels.chid
    ORDER BY ulv_genchannels.sort_id, ulv_opchannels.chid""") % (spid,spid)
    
    conn = my_sql.connect()
    cursor = conn.cursor()
    cursor.execute(m1)
    response = cursor.fetchall()
    conn.close()
    return(response)
Example #15
0
def get_response():
    print(yate.start_response())
       
    form_data = cgi.FieldStorage(encoding='gbk')
    #print form_data
    
    osname =''
    spid=''
    
    
    if form_data:    
        osname = form_data.getvalue('osname')
        spid = form_data.getvalue('spid')       
    
    conn = connect('set_os.ini')
    cursor = conn.cursor()    
    if osname is not None and osname != '':     
        ms = """insert into u_sp (name) values('%s')""" % osname    
        cursor.execute(ms)
        conn.commit()
    EpgUrlAdd()
Example #16
0
def get_response():
    osname =''
    spid=''    
    pickosmac=''
    mac1=''
    mac2=''          
    #print(Osyate.start_response())           
    form_data = cgi.FieldStorage()     
    if form_data: 
        osname = form_data.getvalue('osname')
        spid = form_data.getvalue('spid')        
        pickosmac = form_data.getvalue('pickosmac')
        mac1 = form_data.getvalue('mac1')
        mac2 = form_data.getvalue('mac2')    
    
    conn = connect('set_os.ini')
    cursor = conn.cursor()
    if pickosmac is not None and pickosmac != '' and  ((mac1 is not  None and mac1 != '' ) or (mac2 is not None and mac2 != '')):       
        cursor.execute('''insert into u_devices (mac_l,mac_u,sp_id) values('%s','%s',%s)''' % (mac1,mac2,pickosmac))
        conn.commit()  
    editMac()
Example #17
0
def editMac():
    conn = connect('set_os.ini')
    cur = conn.cursor()            
    '''
    #Print table on browser
    '''
    cur.execute('''select u_sp.id,u_devices.id,u_sp.name, u_devices.mac_l,u_devices.mac_u 
    from u_devices,u_sp,u_hurl 
    where u_sp.id=u_devices.sp_id and u_hurl.spid = u_sp.id and u_hurl.statusid <> 2 ''')
    results = cur.fetchall()
    conn.close()
    print(Osyate.start_response())
    print(Osyate.mac_t1())
    path = 'null'
    if results != ():
        for row in results:    
            mixid=''.join([str(row[0]),'&',str(row[1])])
            #print mixid
            print(Osyate.mac_t2(mixid,row[2],row[3],row[4]))
    print(Osyate.mac_t3('deal_editMac.py'))    
    print(Osyate.include_footer())
Example #18
0
 def connect(self):
     if dbname is not None:
         return(my_sql.connect(dbname))
     else:
         return(my_sql.connect())