Exemplo n.º 1
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("确定"))
Exemplo n.º 2
0
def ft_channels_editFirst():    
    obj = deal_mysql()
    msg = ('''SELECT ulv.channel_id,tvs.chname 
    from ulv_genchannels as ulv
    inner join tvs_channel as tvs
    on tvs.chid=ulv.channel_id order by ulv.sort_id, ulv.channel_id;''')
    
    result = obj.askdata(msg)
    headers = ["频道名称"]
    print(yate.start_response())
    print(yate.include_header("频道维护"))       
    print(yate.start_form("ft_channels_edit.py"))
    print(yate.start_table(tb_width="100%", tb_border="1px solid"))
    print(yate.tb_header(headers))  
    print(yate.start_row())
    print(yate.select('which_chid'))
    #for array in result:        
    print(yate.select_option(result))
    print(yate.end_select())
    print(yate.end_row()) 
    print(yate.start_row())
    print(yate.end_form("确定"))
    print(yate.end_row())
    print(yate.end_table())   
    obj.Close()
Exemplo n.º 3
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"}))
Exemplo n.º 4
0
def select_sp():    
    
    obj = deal_mysql("uspset.ini")
    msg =  '''select id,name from u_sp'''
    results = obj.askdata(msg)
    obj.Close()
    
    headers = ["运营商名称"]
    print(yate.start_response())
  
    print(yate.include_header("首页运营"))

    print(yate.start_form("op_guidepage_arrange.py"))    
    print(yate.start_table(tb_width="50%", tb_border="1px solid"))
    print(yate.tb_header(headers))
    for array in results:
        print(yate.start_row())
        print(yate.checked_radio_button('which_spid',[array[0],array[1]]))
        print(yate.end_row())
    print(yate.end_table())
    print(yate.start_table(tb_width="50%", tb_border="1px solid"))
    print(yate.start_row())
    print(yate.end_form("确定"))
    print(yate.end_row())
    print(yate.end_table())        
Exemplo n.º 5
0
def do_web_process():
    #test functions for yate.py
    print(yate.start_response())
    print(yate.start_response("text/plain"))
    print(yate.start_response("application/json"))
    print(yate.include_header("Test title for my web application in python test"))
    print(yate.include_footer({'Home':'/index.html', 'Select':'/cgi-bin/select.py'}))
    print(yate.start_form("/cgi-bin/process-athlete.py"))
    #print(urllib.request.urlopen('http://192.168.0.1/test.py', urllib.parse.urlencode({'a':'c'})))
    print(urllib.parse.urlencode({'a':'c'}))
    
    the_files = ['testdata/sarah2.txt', 'testdata/james2.txt', 'testdata/mikey2.txt']
    data = put_to_store(the_files)
    for each_data in data:
        print(data[each_data].name+' '+data[each_data].dob)
    data_copy = get_from_store()
    for each_data in data_copy:
        print(data_copy[each_data].name+' '+data_copy[each_data].dob)
    #start simple http server for test
    simple_http_server_test()
    pass
Exemplo n.º 6
0
def channels_operation(sp_id):  
    chidDic  = dict() #store the checked chid from sp_id
    obj = deal_mysql()
    
    msg = ('''SELECT ulv.channel_id,tvs.chname 
    from ulv_genchannels as ulv
    inner join tvs_channel as tvs
    on tvs.chid=ulv.channel_id order by ulv.sort_id, ulv.channel_id;''')
    
    msgn = ('''SELECT chid,sp_id from ulv_opchannels where sp_id=%d''' % int(sp_id))
    
    result = obj.askdata(msg)    
    checked = obj.askdata(msgn)
    for ele in checked:
        chidDic[ele[0]] = ele[1]
    nobj = deal_mysql('uspset.ini')
    msgs = '''select name from u_sp where id=%s''' % int(sp_id)
    response = nobj.askdata(msgs)
    
    headers = ["频道名称", "频道编号"]
    print(yate.start_response())
  
    print(yate.include_header("频道运营"))

    print(yate.start_form("op_channels_generate.py"))
    print(yate.start_table(tb_width="50%", tb_border="1px solid"))
    theader = ['运营商']
    print(yate.tb_header(theader))
    print(yate.start_row())
    print('<input type="radio" checked="checked" name="which_sp" value="'+(sp_id)+'"/>"'+response[0][0]+'"')
    print(yate.end_row())
    print(yate.end_table())
    print(yate.start_table(tb_width="50%", tb_border="1px solid"))
    print(yate.tb_header(headers))
    for array in result:
        if chidDic.get(array[0],None)==None:
            print(yate.do_operationtable(array))
        else:
            print(yate.checked_operationtable(array))
    print(yate.end_table())
    print(yate.start_table(tb_width="50%", tb_border="1px solid"))
    print(yate.start_row())
    print(yate.end_form("确定"))
    print(yate.end_row())
    print(yate.end_table())    
    obj.Close()
    nobj.Close()
Exemplo n.º 7
0
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())
Exemplo n.º 8
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())
Exemplo n.º 9
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()
Exemplo n.º 10
0
def print_operationboundary():
    obj = deal_mysql('uspset.ini')
    msg = '''select id,name from u_sp;'''
    response = obj.askdata(msg)
    headers = ["运营商"]
    print(yate.start_response())
    print(yate.include_header("运营发布"))     
   
    print("<p ><b>点击下面的运营商名称可选择要发布的频道</b></p>")            
    print(yate.start_table(tb_width="50%", tb_border="1px solid"))
    print(yate.tb_header(headers))     
    print(yate.start_div('channel_div'))
    print(yate.start_form("op_channels_select.py"))
    for element in response:
        print('<tr><td>')        
        print(yate.radio_button("which_sp",element)) 
        print('</tr></td>')        
    print(yate.start_row())
    print(yate.end_form("确定"))
    print(yate.end_row())
    print(yate.end_table())
    print(yate.end_div())          
    obj.Close()
Exemplo n.º 11
0
#! /usr/local/bin/python3

import cgi
import sqlite3

import yate

print(yate.start_response('text/plain'))

form = cgi.FieldStorage()
the_id = form_data['Athlete'].value
the_time = form_data['Time'].value

connection = sqlite3.connect('coachdata.sqlite')
cursor = connection.cursor()
cursor.execute("INSERT INTO timing_data (athlete_id, value) VALUES (?, ?)",
                       (the_id, the_time))
connection.commit()
connection.close()

print('OK.')
Exemplo n.º 12
0
def generate_names():
    athletes = athletemodel.get_names_from_store()
    json_athletes = json.dumps(sorted(athletes))
    print(yate.start_response('application/json'))
    print(json_athletes)
Exemplo n.º 13
0
def generate_names():
     athletes = athletemodel.get_names_from_store()
     json_athletes = json.dumps(sorted(athletes))
     print(yate.start_response('application/json'))
     print(json_athletes)
import cgi
import json
import athletemodel
import yate
import requests
# import cgitb
# cgitb.enable()

url = "http://127.0.0.1:8089/cgi-bin/json_back_timing_data.py"
athletes = json.loads(requests.get(url, timeout=4).text)

print(yate.start_response("application"))
print(yate.include_header("---'NUAC's Timing Data---------------"))
print(
    yate.include_header("Athlete:" + athletes['Name'] + "|dob:" +
                        athletes['Bob']))

print(yate.para("The top3 times is:"))
print(yate.u_list(athletes['top3']))

print(yate.include_footer({"Home": "/index.html"}))
print(yate.include_footer({"Other athletes":
                           "/cgi-bin/json_generate_list.py"}))
Exemplo n.º 15
0
import yate
import cgitb
cgitb.enable()

print(yate.start_response("text/html"))
print(yate.include_header("Coach Kelly's List of Athletes"))
print(yate.do_form("add_timing_data.py", ['TimeValue'], submit_txt='Send'))
print(yate.include_footer({"HOME": "/index.html"}))
Exemplo n.º 16
0
import cgi  # 导入cgi库
import athletemodel
import yate

athletes = athletemodel.get_from_store()

form_data = cgi.FieldStorage()  # 获取所有表单数据并放在一个字典中
athlete_name = form_data['which_athlete'.value]

print(yate.start_response())  # 总是从一个content-type行开始
print(yate.include_header("Coach Kelly's Timing Data"))  # 开始生成Web页面,提供一个合适的标题
print(
    yate.header("Athlete:" + athlete_name + ",DOB: " +
                athletes[athlete_name].dob + "."))
print(yate.para("The top times for this athlete are:"))
print(yate.u_list(athletes[athlete_name].top3()))
print(
    yate.include_footer({
        "Home": "/index.html",
        "Select another athlete": "generate_list.py"
    }))
Exemplo n.º 17
0
#! /usr/local/bin/python3

import json
import athletemodel
import yate

names = athletemodel.get_namesID_from_store()

print(yate.start_response(
    'application/json'))  # start with the appropriate "Content-type" line
print(json.dumps(
    sorted(names)))  # sort "names", then convert to JSON and send to STDOUT
Exemplo n.º 18
0
def main():
    form_data = cgi.FieldStorage()
    
    print(yate.start_response())
    print(yate.include_header('Estatísticas para Loterias do Brasil'))
    
    if not form_data:
        print(yate.start_form('', 'jogos.py'))
        print(yate.drop_box('Jogo: ', 'Jogos', {'Quina':'Quina',
            'Mega-Sena': 'Mega-Sena',
            'LotoFácil':'LotoFácil'}, 'Mega-Sena'))
    
        print(yate.drop_box('Estatística: ', 'Estat', {
            'doze': 'Dezenas Mais Sorteadas',
            'rule': 'Distribuição entre Pares e Impares',
            'wors': 'Maior tempo sem ser sorteado',
            'more': 'Mais Sorteado',
            'aver': 'Média de tempo sem ser sorteado',
            'sugs': 'Sugere números com melhor Escore Z',
            'sugl': 'Sugere números menos sorteados recentemente',
            'sugm': 'Sugere números sorteados recentemente',
            'last': 'Última vez sorteado',
            'unit': 'Unidades Mais Sorteadas'},
            'more'))
    
        print(yate.end_form('Enviar'))
    
    elif form_data.getvalue('Jogos') and form_data.getvalue('Estat'):
        jogo = form_data.getvalue('Jogos')
        estat = form_data.getvalue('Estat')
        if jogo == 'Quina':
            obj = QuinaStats('../data/D_QUINA.HTM')
        elif jogo == 'Mega-Sena':
            obj = SenaStats('../data/d_megasc.htm')
        elif jogo == 'LotoFácil':
            obj = LotoFacilStats('../data/D_LOTFAC.HTM')
        else:
            print(yate.para('Opção Inexistente'))
            print(yate.include_footer('&copy LotoEstat 2012'))
            return
    
        if form_data.getvalue('Estat') == 'more':
            print(yate.header('Números Mais Sorteados'))
            print(yate.para('Lista decrescente dos números mais sorteados da ' + form_data.getvalue('Jogos') + '.'))
            
            to_print = obj.prepare_to_print('More', for_print=False)
            print(yate.start_tb(['Dezena ', ' Número de Vezes Sorteado']))
            for each in to_print:
                print(yate.inner_tb([each[0],each[1]]))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'rule':
            print(yate.header('Distribuição entre Pares e Impares'))
            print(yate.para('Combinação de pares e ímpares entre os números da ' + form_data.getvalue('Jogos') + '.'))
            to_print = obj.print_rule_even_by_odd(for_print=False) 
            print(yate.start_tb(['Dezenas Pares ', ' Dezenas Ímpares ', ' Número de Vezes Sorteado']))
            p = re.compile('\d+')
            for each in to_print:
                even, odd = p.findall(each[0])
                print(yate.inner_tb([even, odd, each[1]]))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'unit':
            print(yate.header('Unidades Mais Sorteadas'))
            print(yate.para('Lista das Unidades mais Sorteadas dos Jogos da ' + form_data.getvalue('Jogos') + '.'))
            to_print = obj.print_more_often_unit(for_print=False) 
            print(yate.start_tb(['Dezenas terminadas em ', ' Número de Vezes Sorteado']))
            p = re.compile('\d+')
            for each in to_print:
                unidade = p.findall(each[0])
                print(yate.inner_tb([unidade[0], each[1]]))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'doze':
            print(yate.header('Dezenas Mais Sorteadas'))
            print(yate.para('Lista das Dezenas mais Sorteadas dos Jogos da ' + form_data.getvalue('Jogos') + '.'))
            to_print = obj.print_more_often_dozen(for_print=False) 
            print(yate.start_tb(['Dezenas Começadas por ', ' Número de Vezes Sorteado']))
            p = re.compile('\d+')
            for each in to_print:
                dezena = p.findall(each[0])
                print(yate.inner_tb([dezena[0], each[1]]))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'last':
            print(yate.header('Última vez Sorteado'))
            print(yate.para('A quanto tempo a dezena não é sorteada entre os números premiados da ' + form_data.getvalue('Jogos') + '.'))
            
            to_print = obj.prepare_to_print('Last', for_print=False)
            print(yate.start_tb(['Dezena ', ' Tempo sem ser sorteada']))
            for each in to_print:
                print(yate.inner_tb([each[0],each[1]]))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'wors':
            print(yate.header('Maior tempo sem ser sorteado'))
            print(yate.para('Pior tempo de espera que um número aguardou para ser sorteado entre todos os sorteios da ' + form_data.getvalue('Jogos') + '.'))
            
            to_print = obj.prepare_to_print('Worst', for_print=False)
            print(yate.start_tb(['Dezena ', ' Pior tempo sem ser sorteada']))
            for each in to_print:
                print(yate.inner_tb([each[0],each[1]]))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'aver':
            print(yate.header('Média de tempo sem ser sorteado'))
            print(yate.para('Tempo médio que um número leva até ser sorteado, obtidos à partir do histórico de resultados  da ' + form_data.getvalue('Jogos') + '.'))
            
            to_print = obj.prepare_to_print('Average', for_print=False)
            print(yate.start_tb(['Dezena ', ' Média de espera entre dois sorteios']))
            for each in to_print:
                print(yate.inner_tb([each[0],each[1]]))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'sugm':
            print(yate.header('Sugere números sorteados recentemente'))
            print(yate.para('Ordena os números da ' + form_data.getvalue('Jogos') + ' levando em conta as estatísticas individuais, favorecendo os números que saíram com mais frequencia e que foram sorteados recentemente.'))
            to_print = obj.suggest_num(method='Most Recently', for_print=False)
            if form_data.getvalue('Jogos') == 'Quina':
                dez_sug = 7 
            elif form_data.getvalue('Jogos') == 'Mega-Sena':
                dez_sug = 15 
            elif form_data.getvalue('Jogos') == 'LotoFácil':
                dez_sug = 15 

            cabecalho_tabela = []
            for num in range(1, dez_sug + 1):
                cabecalho_tabela.append(str(num) + 'ª dezena')
            print(yate.start_tb(cabecalho_tabela))
            lis = []
            for each in to_print[:dez_sug]:
                lis.append(each[0])
            print(yate.inner_tb(lis))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'sugl':
            print(yate.header('Sugere números menos sorteados recentemente'))
            print(yate.para('Ordena os números da ' + form_data.getvalue('Jogos') + ' levando em conta as estatísticas individuais, favorecendo os números que saíram com mais frequencia e que estão a mais tempo sem serem sorteados.'))
            to_print = obj.suggest_num(method='Least Recently', for_print=False)
            if form_data.getvalue('Jogos') == 'Quina':
                dez_sug = 7 
            elif form_data.getvalue('Jogos') == 'Mega-Sena':
                dez_sug = 15
            elif form_data.getvalue('Jogos') == 'LotoFácil':
                dez_sug = 15

            cabecalho_tabela = []
            for num in range(1, dez_sug + 1):
                cabecalho_tabela.append(str(num) + 'ª dezena')
            print(yate.start_tb(cabecalho_tabela))
            lis = []
            for each in to_print[:dez_sug]:
                lis.append(each[0])
            print(yate.inner_tb(lis))
            print(yate.end_tb())
        
        elif form_data.getvalue('Estat') == 'sugs':
            print(yate.header('Sugere números com melhor escore padrão'))
            print(yate.para('Ordena os números da ' + form_data.getvalue('Jogos') + ' levando em conta o escore padrão de cada um, favorecendo os números com menor desvio padrão da média de tempo de espera para um número ser sorteado.'))
            to_print = obj.suggest_num(method='Score', for_print=False)
            if form_data.getvalue('Jogos') == 'Quina':
                dez_sug = 7 
            elif form_data.getvalue('Jogos') == 'Mega-Sena':
                dez_sug = 15
            elif form_data.getvalue('Jogos') == 'LotoFácil':
                dez_sug = 15

            cabecalho_tabela = []
            for num in range(1, dez_sug + 1):
                cabecalho_tabela.append(str(num) + 'ª dezena')
            print(yate.start_tb(cabecalho_tabela))
            lis = []
            for each in to_print[:dez_sug]:
                lis.append(each[0])
            print(yate.inner_tb(lis))
            print(yate.end_tb())
        
        print(yate.header('Atualizado em : %s', header_level=6) % obj.print_updated_data())

    else :
        print(yate.para('Opção por Jogo ou Estatística não efetuada.'))
    
    print(yate.include_footer('&copy LotoEstat 2012'))
Exemplo n.º 19
0
#! /usr/local/bin/python3
# -*- coding:utf-8 -*-


import cgi
import json
import yate
import athletemodel


form_data= cgi.FieldStorage()
athlete_name= form_data['which_athlete'].value
athlete= athletemodle.get_athlete_from_id(athlete_id)


print(yate.start_response('application/json'))
print (json.dumps(athletes[athlete_name].to_dict))
Exemplo n.º 20
0

print(dir())

the_files = ['sarah2.txt', 'james2.txt', 'mikey2.txt', 'julie2.txt']
data = put_to_store(the_files)
print(data)

for each_athlete in data:
	print(data[each_athlete].name + ' ' + data[each_athlete].dob)

data_copy = get_from_store()
for each_athlete in data_copy:
	print(data_copy[each_athlete].name + ' ' + data_copy[each_athlete].dob)

print(yate.start_response())
print(yate.start_response("text/plain"))
print(yate.start_response("application/json"))
print(yate.include_header("Welcome to my home on the web!"))
print(yate.include_footer({'Home': '/index.html', 'Select': '/cgi-bin/select.py'}))
print(yate.include_footer({}))
print(yate.start_form("/cgi-bin/process-athlete.py"))
print(yate.end_form())
print(yate.end_form("Click to Confirm Your Order"))
for fab in ['John', 'Paul', 'George', 'Ringo']:
	print(yate.radio_button(fab, fab))
print(yate.u_list(['Life of Brian', 'Holy Grail']))
print(yate.header("Welcome to my home on the web"))
print(yate.header("This isa sub-sub-sub-sub-heading", 5))
print(yate.para("Was it worth the wait? We hope it was..."))
Exemplo n.º 21
0
#! /usr/local/bin/python3

import sys				# for debugging purposes
import cgi
import json
import athletemodel
import yate
from athletelist import AthleteList

form_data = cgi.FieldStorage()						# process the stat send with the request and extract the ahtlete's name
athlete_id = form_data['which_athlete'].value
athlete = athletemodel.get_athlete_from_id(athlete_id)
print(yate.start_response('application/json'))		# start a web response, with JSON as the data type
print(json.dumps(athlete))							# include the indicated athlete's data in the web response, formatted by JSON
Exemplo n.º 22
0
#! /usr/local/bin/python3 
import yate
print(yate.start_response('text/html')) 
print(yate.do_form('add_timing_data.py', ['TimeValue'], text='Send'))
Exemplo n.º 23
0
    Note that data in the enviorment is available to
    your code as dictionary.
"""

# ! /usr/local/bin/python3

import cgi
import os
import time
import sys
import yate

# Querying three enviornment variables and
# assign their values to variables.

print(yate.start_response('text/plain'))
addr = os.environ['REMOTE_ADDR']
host = os.environ['REMOTE_HOST']
method = os.environ['REQUEST_METHOD']

# Get the Current Time
cur_time = time.asctime(time.localtime())

# Display the queried data on standard error
print(host + ", " + addr + ", " + cur_time + ": " +
      method + ": ", end='', file=sys.stderr)

form = cgi.FieldStorage()

for each_form_item in form.keys():
    print(each_form_item + '->' + form[each_form_item].value, end='',
Exemplo n.º 24
0
#! /usr/local/bin/python3

import sys  # for debugging purposes
import cgi
import json
import athletemodel
import yate
from athletelist import AthleteList

form_data = cgi.FieldStorage(
)  # process the stat send with the request and extract the ahtlete's name
athlete_id = form_data['which_athlete'].value
athlete = athletemodel.get_athlete_from_id(athlete_id)
print(yate.start_response(
    'application/json'))  # start a web response, with JSON as the data type
print(
    json.dumps(athlete)
)  # include the indicated athlete's data in the web response, formatted by JSON
Exemplo n.º 25
0
def guidpage_arrange():
    spid = get_formData('which_spid')
    obj = deal_mysql()
    msg = '''select id,alias from u_items'''
    results = obj.askdata(msg)
    
    nummsg = '''select item_id,position from u_homepage where spid=%s''' % spid[0]
    homeitem= obj.askdata(nummsg)   
    
    obj.Close()
    
    nobj = deal_mysql('uspset.ini')
    nmsg = """select name from u_sp where id=%s""" % spid[0]
    spname = nobj.askdata(nmsg)   
    nobj.Close()
      
    
    #headers = ["频道名称", "频道编号"]
    print(yate.start_response())
    aa = "频道运营"
    aa.encode('utf-8')
  
  
    print(yate.include_header(aa))

    print(yate.start_form("op_guidepage_storage.py"))
    
    print(yate.start_table(tb_width="75%", tb_border="1px solid"))    
    print(yate.start_row())
    print('<input type="radio" checked="checked" name="which_sp" value="'+(spid[0])+'"/>"'+spname[0][0]+'"')
    
    print(yate.end_row())
    print(yate.end_table())
    
    print(yate.start_table(tb_width="75%", tb_border="5px solid")) 
    '''
    spid has in u_homepage
    '''
    if homeitem !=():        
        position = dict()
        for eachItem in homeitem:
            position.update({eachItem[0]:eachItem[1]})
        for i in range(2):    
            print(yate.start_tr())
            for iters in range(3):
                if i == 1:
                    iters = iters + 3
                print(yate.start_td())
                pos = 'pos'+str(iters)
                print(yate.select(pos))
                for item in results:
                    if item[0] in position.keys() and position[item[0]]==iters+1:                        
                        print(yate.select_optione_with_selected(item,True))
                    else:
                        print(yate.select_optione_with_selected(item))                        
                print(yate.end_select())
                print(yate.end_td())
            print(yate.end_tr())
                     
    
    else:
        for i in range(2):                          
            print(yate.start_tr())        
            for iters in range(3):
                if i == 1:
                    iters = iters + 3
                print(yate.start_td())
                pos = 'pos'+str(iters)
                print(yate.select(pos))        
                print(yate.select_option(results))
                print(yate.end_select())
                print(yate.end_td())
            print(yate.end_tr())    
    
    print(yate.end_table())
    
    print(yate.start_table(tb_width="75%", tb_border="1px solid"))
    print(yate.start_row())
    print(yate.end_form("确定"))
    print(yate.end_row())    
    print(yate.end_table())  
    print('</body></html>')
Exemplo n.º 26
0
import json
import athletemodel
import yate

names = athletemodel.get_namesID_from_store()
print(yate.start_response('application/json'))
print(json.dumps(sorted(names)))
Exemplo n.º 27
0
import yate

print(yate.start_response("text/html"))
print(yate.do_form("add_timing_data.py", {"TimeValue": "80"}, text="Send"))
Exemplo n.º 28
0
import json
import yate
import athletemodel

print(yate.start_response(resp="application/json"))
print(json.dumps(sorted(athletemodel.get_namesID_from_store())))

Exemplo n.º 29
0
import athletemodel
import yate
import glob  #this module lets you query your operating system for a list of file names

data_files = glob.glob(
    "data/*.txt"
)  #creating a list of the file names of type '*.txt' within folder 'data'
athletes = athletemodel.put_to_store(
    data_files)  #creating a dictionary of athletes from the list of data files

print(yate.start_response())  #always start with a Content-type line
print(yate.include_header(
    "Coach Kelly's List of Athletes"))  #provide a title for the page

print(
    yate.start_form("generate_timing_data.py")
)  #start generating the form providing the name of the server-side program to link to.
print(yate.para("Select an athlete from the list to work with:"))

for each_athlete in athletes:  #generate a radio button for each athlete
    print(yate.radio_button("which_athlete", athletes[each_athlete].name))

print(yate.end_form(
    "Select"))  # end the form with a custom text for the submit button

print(yate.include_footer({"Home": "/index.html"
                           }))  # a link to go back to the Home page
Exemplo n.º 30
0
#!/usr/local/bin/python3

import yate

print(yate.start_response('text/html'))
print(yate.do_form('add_timing_data_test.py', ['TimeValue'], text='Send'))
Exemplo n.º 31
0
import time
import cgi
import os
import sys
import yate
import cgitb
import sqlite3
cgitb.enable()

print(yate.start_response("text/plain"))
addr = os.environ["REMOTE_ADDR"]
host = os.environ["REMOTE_HOST"]
method = os.environ["REQUEST_METHOD"]
cur_time = time.asctime(time.localtime())

print("%s, %s, %s: %s:" %(host, addr, cur_time, method), end="", file=sys.stderr)

form=cgi.FieldStorage()
athlete_id = form["Athlete"].value
athlete_time = form["TimeValue"].value

connection = sqlite3.connect("coachdata.sqlite")
cursor = connection.cursor()
cursor.execute("insert into timing_data(athlete_id, value) values(?, ?)", (athlete_id, athlete_time))
connection.commit()
connection.close()
print("OK.")
Exemplo n.º 32
0
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 12 11:50:51 2018

@author: dell]

generate_list
"""

import athletemodel
import yate
import glob

data_files = glob.glob("data/*.txt")
athletes = athletemodel.put_to_store(data_files)

print(yate.start_response())
print(yate.include_header("Coach Kelly's List of Athletes"))
print(yate.start_form("generate_timing_data.py"))
print(yate.para("Select an athlete from the list to work with:"))

for each_athlete in athletes:
    print(yate.radio_button("Which_athlete", athletes[each_athlete].name))
print(yate.end_form("select"))

print(yate.include_footer({"Home": "/index.html"}))
Exemplo n.º 33
0
#f = open(filename, "w")

NewXML = MySQLtoXML('')
for each_form_item in form.keys():
    if each_form_item == "txtMySQL":
        NewXML = MySQLtoXML(form["txtMySQL"].value)
    break

if NewXML.script != "":
    form["txtMySQL"].value = NewXML.GetXML()
    #form["txtXML"].value = "wilre!"


#f.close()
page = ""
page = page + (yate.start_response())
page = page + (yate.include_header("CodeVald | MySql -> XML"))

#Menu
page = page + (yate.addcontent('templates/menu_open.html'))
page = page + (yate.addcontent('templates/menu_body.html'))
page = page + (yate.addcontent('templates/menu_close.html'))
page = page + (yate.addcomment('END SIDEBAR'))
#End Menu
#Content
page = page + (yate.addcomment('BEGIN CONTENT'))
page = page + (yate.opendiv('page-content-wrapper'))
page = page + (yate.opendiv('page-content-wrapper'))
page = page + (yate.opendiv('page-content'))
page = page + (yate.addtitle("CodeVald", "MySql -> XML"))
page = page + (yate.addcomment('BEGIN PAGE CONTENT'))
#! /usr/local/bin/python3

import cgitb
cgitb.enable()

import athletelist_model  #to get data from model py
import yate  #to html texts
import cgi

athletes = athletelist_model.get_from_store()   #get data from pickled format

#get form data
form_data = cgi.FieldStorage()
athlete_name = form_data['which_athlete'].value

#print html page
print(yate.start_response())
print(yate.include_header("Coach Kelly's Timing Data"))
print(yate.header("Athlete: " + athlete_name + ", DOB: " +athletes[athlete_name].dob + "."))
	
print(yate.para("The top times for this athlete are:"))

print(yate.u_list(athletes[athlete_name].top3()))

print(yate.include_footer({"Home": "/index.html","Select another athlete": "athletelist_generate_list.py"}))
Exemplo n.º 35
0
# 获取输入数据
# form_data = cgi.FieldStorage()
# for each_form_item in form_data.keys():
# print(each_form_item + '->' + form_data[each_form_item].value, end = '', file = sys.stderr)

# 换行
# print(file=sys.stderr)
# print("OK.")

import cgi
import sqlite3
import yate

# 设置响应头
print(yate.start_response("text/plain"))

# 数据库名称
db_name = "coachdata.sqlite"
# 获取请求数据
form_data = cgi.FieldStorage()
# 获取ID
athlete_id = form_data["athlete_id"].value
# 获取时间
athlete_time = form_data["athlete_time"].value

# 连接数据库
conn = sqlite3.connect(db_name)
# 打开游标
cursor = conn.cursor()
# 添加数据
#! /usr/bin/env python
import cgitb
cgitb.enable()
import cgi
import yate
import athletemodel

athletes = athletemodel.get_from_store()

form_data = cgi.FieldStorage()
if "which_athlete" not in form_data:
    print "<H1>Error</H1>"
    print "Please choose one athlete."
athlete_name = form_data["which_athlete"].value
the_athlete = athletes[athlete_name]

print yate.start_response()
print yate.include_header("Coach Kelly's Timing Data")
print yate.header("Athlete:" + athlete_name + ", DOB:" + the_athlete.dob + ".")
print yate.para("The top times for " + athlete_name + " are:")
print yate.u_list(the_athlete.top3)
print yate.include_footer({"Home":"index.html", "Select another athlete":"generate_list.py"})
Exemplo n.º 37
0
#! /usr/local/bin/python3

import json
import athletemodel
import yate

names = athletemodel.get_namesID_from_store()

print(yate.start_response('application/json'))	# start with the appropriate "Content-type" line
print(json.dumps(sorted(names)))				# sort "names", then convert to JSON and send to STDOUT