async def main():
    creatematchhistorydbifnotexists()
    regions = config.get('adjustable', 'regions').split(',')
    tasks = []
    regionstoplatforms = {
        "na1": "americas",
        "br1": "americas",
        "la2": "americas",
        "la1": "americas",
        "oc1": "americas",
        "ru": "europe",
        "eun1": "europe",
        "euw1": "europe",
        "tr1": "europe",
        "jp1": "asia",
        "kr": "asia"
    }

    for region in regions:
        platform = regionstoplatforms.get(region)
        panth = pantheon.Pantheon(
            platform,
            key.get('setup', 'api_key'),
            #requestsLoggingFunction=requestsLog,
            errorHandling=True,
            #debug=True
        )
        tasks.append(getmatchhistories(panth, region))
    await asyncio.gather(*tuple(tasks))
    connection.close()
Exemple #2
0
async def main():
    createdbifnotexists()
    regions = config.get('adjustable', 'regions').split(',')
    tasks = []
    for region in regions:
        panth = pantheon.Pantheon(region, key.get('setup', 'api_key'), errorHandling=True, debug=False)
        tasks.append(insertpuuid(panth))
    await asyncio.gather(*tuple(tasks))
def matches():
    key = configparser.ConfigParser()
    key.read('keys.ini')

    region = 'europe'
    panth = pantheon.Pantheon(region, key.get('setup', 'api_key'), errorHandling=True, debug=True)

    return asyncio.run(loadmatchhistory.cleanmatchhistorylist(panth, 'euw1', 1))
def getmatchestorun():
    region = 'euw1'
    panth = pantheon.Pantheon('europe',
                              key.get('setup', 'api_key'),
                              errorHandling=True,
                              debug=True)
    testdb = asyncio.run(
        loadmatchhistory.getmatchhistorylistfromapi(panth, region))
    assert len(testdb) > 0
def matches():
    panth = pantheon.Pantheon('europe',
                              key.get('setup', 'api_key'),
                              errorHandling=True,
                              debug=True)
    matches = ['EUW1_4819630931']
    matchjsons = asyncio.run(loadmatchhistory.apigetmatch(matches, panth))
    assert len(matchjsons) > 0
    return matchjsons
Exemple #6
0
class PredictorConfig(AppConfig):
    name = 'predictor'
    filename = 'OptimizeBrierMaxCat01716961192'
    server = 'NA1'
    model = CatBoostClassifier()
    model.load_model(name + '/' + filename)
    ssl.match_hostname = lambda cert, hostname: True
    # panth = pantheon.Pantheon(server, riotConfig['api_key'], errorHandling=True, debug=False)
    panth = pantheon.Pantheon(server, os.environ['RIOT_API_KEY'], errorHandling=True, debug=False)
def matchhistory():
    region = 'europe'
    panth = pantheon.Pantheon(region,
                              key.get('setup', 'api_key'),
                              errorHandling=True,
                              debug=True)
    puuids = [
        'TKln2rK8guuLVAsI0FZJFr6-13-H6n4KpRV08VffOvV3tg2utD1npfdEfGjJsWKd_-6-wo38fngSuA'
    ]
    testdb = asyncio.run(loadmatchhistory.apigetmatchlist(puuids, panth))
    assert len(testdb) > 0
async def test():
    regions = config.get('adjustable', 'regions').split(',')
    tasks = []
    for region in regions:
        panth = pantheon.Pantheon(
            region,
            key.get('setup', 'api_key'),
            #requestsLoggingFunction=requestsLog,
            errorHandling=True,
            #debug=True
        )
        tasks.append(getmatchhistories(panth, region))
    return await asyncio.gather(*tuple(tasks))
Exemple #9
0
async def main():
    creatematchhistorydbifnotexists()
    regions = config.get('adjustable', 'regions').split(',')
    tasks = []
    for region in regions:
        panth = pantheon.Pantheon(
            region,
            key.get('setup', 'api_key'),
            #requestsLoggingFunction=requestsLog,
            errorHandling=True,
            #debug=True
        )
        tasks.append(getmatchhistories(panth))
    await asyncio.gather(*tuple(tasks))
    connection.close()
async def getpuuidtorun(panth, region):
    #print('start'+panth._server)
    asyncio.set_event_loop(asyncio.new_event_loop())
    panth = pantheon.Pantheon(
        region,
        key.get('setup', 'api_key'),
        #requestsLoggingFunction=requestsLog,
        errorHandling=True,
        #debug=True
    )
    challenger = asyncio.run(getmasterplus(panth))
    puuiddb = await grabpuiiddb()
    ladder = puuiddb.merge(challenger,
                           left_on=["summonerid", "region"],
                           right_on=["summonerId", "region"])
    ladder = ladder.loc[ladder['puuid'].notnull()]
    #print(str(len(ladder))+'ladder'+panth._server)
    return ladder
Exemple #11
0
def getladder():
    key = configparser.ConfigParser()
    key.read('keys.ini')

    config = configparser.ConfigParser()
    config.read('config.ini')

    regions = config.get('adjustable', 'regions').split(',')

    alldata = pd.DataFrame()

    for region in regions:
        print(region)
        panth = pantheon.Pantheon(region,
                                  key.get('setup', 'api_key'),
                                  errorHandling=True,
                                  debug=True)
        data = asyncio.run(loadpuuid.getmasterplus(panth))
        alldata = pd.concat([alldata, data])
    return alldata
Exemple #12
0
    def init_elements(self):
        if self._server is None:
            raise Exception("Server needs to be set")
        if self._api_key is None:
            raise Exception("API key needs to be set")

        self._pantheon = pantheon.Pantheon(
            self._server,
            self._api_key,
            requestsLoggingFunction=self._logger.push_request)

        for e in self._elements:
            if issubclass(e.__class__, Manager):
                e.set_pantheon(self._pantheon)
                self._managers.append(e)
            if issubclass(e.__class__, Queue):
                self._queues.append(e)
            if issubclass(e.__class__, Bootstrap):
                e.set_pantheon(self._pantheon)
                self._bootstrap.append(e)

        self._init = True
Exemple #13
0
import asyncio
import pytest

from pantheon import pantheon
from pantheon.utils import exceptions as exc

import os

# API details
api_key = os.environ['PANTHEON_KEY']
server = "euw1"
panth = pantheon.Pantheon(server, api_key, errorHandling=True)

panth_americas = pantheon.Pantheon("americas", api_key, errorHandling=True)
panth_eu = pantheon.Pantheon("eu", api_key, errorHandling=True)

# Summoner details
name = "Canisback"
tag = "EUW1"
accountId = "mCT1-43iYmFMG0-X2efejgX6JBnMneMnGXALxYTE_1nvaQ"
summonerId = "r3jOCGc0_W5N9lg-ZANlC2CSEnn-7wMGm_hZAdo-bxprB_4"
puuid = "S6OWGeKQqY-SCU8931OPdK2zmenypS5Hs_YHv6SrmBDAVMMJpDQeTq8q06tzTFHvNaXWoIf6Fm5iTg"

# League details
leagueId = "d112cf40-35be-11e9-947f-c81f66db01ef"

## Set to True if skipping apex tiers
too_early = False
too_early_tft = False

# Match details
Exemple #14
0
    "EUN1":"eun1",
    "EUW1":"euw1",
    "JP1":"jp1",
    "KR":"kr",
    "LA1":"la1",
    "LA2":"la2",
    "NA1":"na1",
    "OC1":"oc1",
    "TR1":"tr1",
    "RU":"ru"
}


api_key = "API_KEY"

pantheon = {server:panth.Pantheon(servers[server], api_key) for server in servers}

app = Flask(__name__)
app.config['TEMPLATES_AUTO_RELOAD'] = True

def get_set_event_loop():
    try:
        return asyncio.get_event_loop()
    except RuntimeError as e:
        if e.args[0].startswith('There is no current event loop'):
            asyncio.set_event_loop(asyncio.new_event_loop())
            return asyncio.get_event_loop()
        raise e

@app.route('/')
def index():
                              database=key.get('database', 'database'))
cursor = connection.cursor()


def requestsLog(url, status, headers):
    print(url[:100])
    #print(status)
    #print(headers)
    pass


#for debugging
region = "tr1"
panth = pantheon.Pantheon(region,
                          key.get('setup', 'api_key'),
                          requestsLoggingFunction=requestsLog,
                          errorHandling=True,
                          debug=True)


#Create db if does not yet exist
def creatematchhistorydbifnotexists():
    cursor.execute("""CREATE TABLE IF NOT EXISTS MatchHistories(
    id SERIAL PRIMARY KEY,
    participants json,
    match_id text,
    region text,
    game_datetime bigint,
    game_version text,
    game_variation text,
    queue_id int
Exemple #16
0
config = configparser.ConfigParser()
config.read('config.ini')

key = configparser.ConfigParser()
key.read('keys.ini')

connection = psycopg2.connect(host=key.get('database', 'host'),
                              port=5432,
                              user=key.get('database', 'user'),
                              password=key.get('database', 'password'),
                              database=key.get('database', 'database'))

#get tft watcher
region = "euw1"
panth = pantheon.Pantheon(region,
                          key.get('setup', 'api_key'),
                          errorHandling=True)

summonernames = asyncio.run(getchallengerladder(region, panth))

# You must initialize logging, otherwise you'll not see debug output.
#logging.basicConfig()
#logging.getLogger().setLevel(logging.DEBUG)
#requests_log = logging.getLogger("requests.packages.urllib3")
#requests_log.setLevel(logging.DEBUG)
#requests_log.propagate = True

for name in summonernames['summonerId']:
    start = time.time()
    url = config.get('default',
                     'summonerid_url').format(region, name,
Exemple #17
0
                                                tierInfo['point'])
        messages[idx] += '{}승 {}패 승률 : {}%'.format(tierInfo['wins'],
                                                   tierInfo['losses'],
                                                   tierInfo['ratio'])
        #print(messages[idx])

    message = messages[0] + '\n\n' + messages[1]
    bot.sendMessage(LOLALARMCHANNEL, message)
    time.sleep(10)


name = "Hide On Bush"
if __name__ == '__main__':

    panth = pantheon.Pantheon(server,
                              api_key,
                              errorHandling=True,
                              requestsLoggingFunction=requestsLog,
                              debug=True)
    loop = asyncio.get_event_loop()
    summonerId, accountId = loop.run_until_complete(getSummonerId(name))
    championId_crawl()
    now = datetime.now()
    test_league_entries_by_summonerId(accountId)

    while True:
        nowHour = now.hour
        if nowHour == 16:  ##KST 0
            test_league_entries_by_summonerId(accountId)
        getLastMatchInfo(accountId)
Exemple #18
0
import discord
import json
import asyncio
from pantheon import pantheon
from util.decorator import only_owner
from util.exception import Error, InvalidArgs, NotFound, ALEDException
from util.function import load_json_file, write_json_file

LEAGUE_SCORE = {"IRON": 0, "BRONZE":500, "SILVER":1000, "GOLD":1500, "PLATINUM":2000,
                "DIAMOND":2500, "MASTER":2600, "GRANDMASTER": 2600, "CHALLENGER":2600}
DIV_SCORE = {"IV":0,"III":110,"II":220,"I":330}
QUEUE = {"RANKED_FLEX_SR":"FlexQ", "RANKED_SOLO_5x5":"SoloQ", "RANKED_FLEX_TT":"3v3TT", "RANKED_TFT":"TFT"}
with open("private/rgapikey") as key:
    panth = pantheon.Pantheon("euw1", key.read(), True)

def load_verif():
    return load_json_file("data/summoners")

def load_score():
    return load_json_file("data/rank_score")

def save_score(dic):
    return write_json_file("data/rank_score", dic)

async def get_leader(message, rank):
    scores = load_score()
    verif = load_verif()
    guild = message.guild
    if not guild:
        raise Error("Impoissble de récupérer le classement du serveur")
    guildv = [str(verif[str(member.id)]) for member in guild.members if str(member.id) in verif.keys()]
Exemple #19
0
import asyncio
import pytest

from pantheon import pantheon
from pantheon.utils import exceptions as exc

import os

# API details
api_key = os.environ['PANTHEON_KEY']
server = "euw1"
panth = pantheon.Pantheon(server, api_key, auto_retry=True)

panth_eu = pantheon.Pantheon("eu", api_key, auto_retry=True)

# Summoner details
name = "Canisback"
tag = "EUW1"
accountId = "mCT1-43iYmFMG0-X2efejgX6JBnMneMnGXALxYTE_1nvaQ"
summonerId = "r3jOCGc0_W5N9lg-ZANlC2CSEnn-7wMGm_hZAdo-bxprB_4"
puuId = "S6OWGeKQqY-SCU8931OPdK2zmenypS5Hs_YHv6SrmBDAVMMJpDQeTq8q06tzTFHvNaXWoIf6Fm5iTg"

# League details
leagueId = "d112cf40-35be-11e9-947f-c81f66db01ef"

## Set to True if skipping apex tiers
too_early = False
too_early_tft = False

# Match details
matchId = "EUW1_5742254354"
Exemple #20
0
apikey = "RGAPI-90b23334-2b95-4f70-8d19-699fa10518b8"
sleep_time = 1.21
DEBUG = False
PRINT_LOG = False
version = '<Releases/10.18>'
min_match_id = 4619651258
###############################


def requestsLog(url, status, headers):
    print(url, "DEBUG")
    print(status, "DEBUG")
    print(headers, "DEBUG")


panth = pantheon.Pantheon(server, apikey, errorHandling=True)
loop = asyncio.get_event_loop()


######## GETTING USER SUMMONER_ID #######
#########################################
async def getTFTChallengerLeague():
    try:
        data = await panth.getTFTChallengerLeague()
        await asyncio.sleep(sleep_time)
        return data
    except Exception as e:
        print(e)


async def getTFTGrandmasterLeague():
Exemple #21
0
regions = {
    'br': 'br1',
    'eune': 'eun1',
    'euw': 'euw1',
    'jp': 'jp1',
    'kr': 'kr',
    'lan': 'la1',
    'las': 'la2',
    'na': 'na1',
    'oce': 'oc1',
    'tr': 'tr1',
    'ru': 'ru'
}
champs = {}

panths = {k: pantheon.Pantheon(v, apikey) for k, v in regions.items()}


async def getchamps(region):
    async with httpx.AsyncClient() as client:
        region_info = await client.get(
            f'https://ddragon.leagueoflegends.com/realms/{region}.json'
        )
        region_info = region_info.json()
        lang = 'en_AU'  # region_info['l']
        ver = region_info['n']['champion']
        champdata = await client.get(
            f'https://ddragon.leagueoflegends.com/cdn/{ver}/data/{lang}/'
            'championFull.json'
        )
        champdata = champdata.json()['data']