def summoner(summ): summ = summ.replace(" ", "") # regionlist = [zone.value for zone in Region] regionlist = ['na', 'kr', 'euw', 'eune'] zone_summoners = [] # Try to speed this up by using pure riot json requests simultaneously for all regions? for r in regionlist: cassdb = SQLAlchemyDB(connector, host, dbnames[r]+"?charset=utf8", user, passwd) riotapi.set_data_store(cassdb) riotapi.set_region(r) try: s = riotapi.get_summoner_by_name(summ) if s is not None: zone_summoners.append((r, s)) print("{} from {} appended".format(s.name, r)) except APIError as error: print(error) print(error.error_code) cassdb.close() # attempt to avoid mysql went away if len(zone_summoners) == 0: error = "Summoner with that name not found. Try another one." return render_template('index.html', error=error) patch = riotapi.get_versions()[0] return render_template('zone.html', zone_summoners = zone_summoners, summname = summ, patch = patch)
def test_versions(): int_test_handler.test_result(riotapi.get_versions())
def matchlistpage(zone, name): # Set region and after region is set, fetch latest API version, maybe move the version to a scheduled task if it uses a call. riotapi.set_region(zone) if zone in ['na', 'kr', 'euw', 'eune']: cassdb = SQLAlchemyDB(connector, host, dbnames[zone]+"?charset=utf8", user, passwd) riotapi.set_data_store(cassdb) print("======================") print(zone) print(name) print("======================") patch = riotapi.get_versions()[0] # Used to convert numerals to/from numbers romans = { 'I': 1, 'II': 2, 'III': 3, 'IV': 4, 'V': 5 } print("========== DB MADE Trying to get summoner by name ===========") # Get summoner s = riotapi.get_summoner_by_name(name) print("Summoner object:") print(s) print("id:{} name:{} level:{}".format(s.id, s.name, s.level)) print("========== GOT S, trying to get league entries ===========") try: le = riotapi.get_league_entries_by_summoner(s)[0] entry = le.entries[0] print("Got league entries for ranked") except: print("Couldnt fetch le/entry. Perhaps unranked.") le = None entry = None print("========== Trying to get ranked stats ===========") try: stats = riotapi.get_ranked_stats(s, season=None)[None] except: print("Couldnt fetch ranked stats. Maybe not lv30/never did ranked.") stats = None print("========== Trying to get matches ===========") ml = riotapi.get_match_list(s, seasons=[x.value for x in Season][-1], num_matches=10) if ml is not None: matches = [][-10:] for x in ml: try: m_to_add = riotapi.get_match(x) matches.append(m_to_add) except exc.IntegrityError as ie: print("==SQL ERROR ---> {}".format(ie)) print("==Python traceback==") print(traceback.print_exc()) cassdb.session.rollback() else: matches = [] print("========== Trying to render template ===========") return render_template('matchlist.html', s = s, entry = entry, le = le, matches = matches, patch = patch, stats = stats, zone = zone, round = round, len = len, romans = romans)
def matchlistpage(zone, name): # Set region & fetch latest api version riotapi.set_region(zone) # Set data store # *** REMOVED UNTIL CASSIOPEIA 2.0 *** patch = riotapi.get_versions()[0] # Roman->number conversion romans = { 'I': 1, 'II': 2, 'III': 3, 'IV': 4, 'V': 5 } # Get summoner s = riotapi.get_summoner_by_name(name) print("Summoner object: {}".format(s)) print("ID: {} NAME: {} LEVEL: {}".format(s.id, s.name, s.level)) # Get league entries try: le = riotapi.get_league_entries_by_summoner(s)[0] entry = le.entries[0] print("Got League entries for ranked") except: le = None entry = None print("Couldnt fetch le/entry. Perhaps unranked. Setting le and entry to None. Exception traceback:") print(traceback.print_exc()) # Get ranked stats try: stats = riotapi.get_ranked_stats(s, season=None)[None] print("Got ranked stats") except: stats = None print("Couldnt fetch ranked stats. Perhaps not lv30 or never ranked. Setting stats to None. Exception traceback:") traceback.print_exc() # Get matches # *** DISABLED. PAGE WILL ONLY CHECK IF IN CURRENT GAME THROUGH JAVASCRIPT THEN OFFER CURRENTGAME BUTTON *** print("===== RENDERING TEMPLATE =====") return render_template('matchlist2.html', s = s, entry = entry, le = le, patch = patch, stats = stats, zone = zone, round = round, len = len, romans = romans)