Пример #1
0
def e_sdc_config():
    c = get_config()
    sdc_status = json.loads(requests.get(c['SUI_SDC_URL'] + f'status').content)
    sdc_status = json.dumps(sdc_status, indent=2)
    return render_template('/elements/e_config.html',
                           items=sdc_status,
                           title='SDC CONFIGURATION')
Пример #2
0
def e_current_bout_table():
    c = get_config()

    sbo_status = json.loads(requests.get(c['SUI_SBO_URL'] + 'status').content)

    p1name = sbo_status['bout']['p1name']
    p1bets = sbo_status['bout']['p1total']

    p2name = sbo_status['bout']['p2name']
    p2bets = sbo_status['bout']['p2total']

    red = {
        'team': 'RED',
        'name': p1name,
        'bets': p1bets,
        'wins': None,
        'losses': None,
        'elo': None,
        'num_upsets': None,
        'current_streak': None,
        'date_of_debut': None
    }
    blue = {
        'team': 'BLUE',
        'name': p2name,
        'bets': p2bets,
        'wins': None,
        'losses': None,
        'elo': None,
        'num_upsets': None,
        'current_streak': None,
        'date_of_debut': None
    }

    try:
        req_p1 = requests.get(c['SUI_SDC_URL'] +
                              f'exactfighter?name={p1name}').content
        rf = json.loads(req_p1)
        for k, v in red.items():
            if k in rf.keys():
                red[k] = rf[k]
    except:
        pass

    try:
        req_p2 = requests.get(c['SUI_SDC_URL'] +
                              f'exactfighter?name={p2name}').content
        bf = json.loads(req_p2)
        for k, v in blue.items():
            if k in bf.keys():
                blue[k] = bf[k]
    except:
        pass

    current_bout = [red, blue]
    print(current_bout)
    return render_template('/elements/e_table.html',
                           items=current_bout,
                           table_title='CURRENT BOUT')
Пример #3
0
def e_latest_fighters_table():
    c = get_config()
    latest_fighters = json.loads(
        requests.get(c['SUI_SDC_URL'] +
                     f'fighters?num=10&sort=id&sort_type=bottom').content)
    return render_template('/elements/e_table.html',
                           items=latest_fighters,
                           table_title='LATEST FIGHTERS')
Пример #4
0
def get_default_connection():
    c = get_config()
    # print(f"Connecting to {c['sql_default_db']}")
    conn = psycopg2.connect(database=c['SDC_SQL_DEFAULT_DB'],
                            user=c['SDC_SQL_USER'],
                            password=c['SDC_SQL_SECRET'],
                            host=c['SDC_SQL_HOST'],
                            port=c['SDC_SQL_PORT'])
    return conn
Пример #5
0
def fighters():
    c = get_config()
    page = request.args.get('page', default=0, type=int)
    sort = request.args.get('sort', default='name')

    fighters = json.loads(
        requests.get(c['SUI_SDC_URL'] + f'fighters?sort={sort}').content)
    num_fighters = len(fighters)

    page_size = 100
    max_page = num_fighters // page_size
    if num_fighters % page_size > 0:
        max_page = max_page + 1

    disp_pages_start = page - 5

    disp_pages_end = disp_pages_start + 50
    if disp_pages_end > max_page:
        disp_pages_end = max_page
        disp_pages_start = max_page - 50

    if disp_pages_start < 0:
        disp_pages_start = 0

    pages = list(range(disp_pages_start, disp_pages_end))
    if pages[0] != 0:
        pages.insert(0, 0)
    if pages[-1] != max_page:
        pages.append(max_page)

    if page > max_page:
        page = max_page

    first_index = page * page_size
    last_index = first_index + page_size

    if last_index > len(fighters):
        last_index = len(fighters)
        first_index = last_index - page_size

    return render_template('searchdata.html',
                           title='fighters',
                           items=fighters[first_index:last_index],
                           table_title='FIGHTERS',
                           pages=pages)
Пример #6
0
from app import app
from app.utils.conf_parse import get_config

if __name__ == '__main__':
    c = get_config()
    app.run(debug=False, host=c['SUI_HOST'], port=c['SUI_PORT'])
Пример #7
0
def api_v1_status():
    conf = get_config()
    conf['SDC_SQL_USER'] = '******'
    conf['SDC_SQL_SECRET'] = 'CHECK CONFIG'
    conf["is_running"] = True
    return jsonify(conf)
Пример #8
0
def e_sui_config():
    sui_status = get_config()
    sui_status = json.dumps(sui_status, indent=2)
    return render_template('/elements/e_config.html',
                           items=sui_status,
                           title='SUI CONFIGURATION')
Пример #9
0
def api_v1_status():
    c = get_config()
    return jsonify(c)
Пример #10
0
 def __init__(self):
     print('CREATE BOUT OBSERVER')
     self.bout = ""
     self.c = get_config()
     self.p_list = []