Beispiel #1
0
 def join(self, userName, ip):
     d = call_api(id=userName, api="LOL", ext="USER")
     if d is None:
         return dict(error="Summoner Not Found!", errorType="JOIN")
     u = dbcls.User.all().filter('internalName =', userName).get()
     if u:
         return dict(error="Summoner is already in the system!", errorType="JOIN")
     return self.create_user(userName=userName, d=d, ip=ip)
def word_tokenize(txt):
    try:
        data = {'txt': txt}
        respond = utils.call_api(data, "http://localhost:4567/tokenize", "POST")
        if respond.status_code == 200:
            return respond.text
        return txt
    except:
        return txt
 def thread_handler(self, client_sock, address):
     size = 1024
     data = ""
     transfer = client_sock.recv(size)
     data = data + transfer.decode('utf-8')
     req = parse_req(data)
     resp = call_api(req, self.cache, self.lsmtree, self.lock, self.fine_grained_lock)
     client_sock.send(resp.encode('utf-8'))
     #self.cache.show()
     client_sock.close()
Beispiel #4
0
 def get(self):
     userList = User.all()
     for user in userList:
         d = call_api(id=user.internalName, api="LOL", ext="USER")
         if d is None:
             user.marked = True
             break
         user.internalName, user.displayName, user.iconID = d["data"]["internalName"], d["data"]["name"], d["data"]["icon"]
         user.put()
     get_user_list(update=True)
 def thread_handler(self, client_sock, address):
     size = 1024
     data = ""
     print("in handler")
     while True:
         transfer = client_sock.recv(size)
         data = data + transfer.decode('utf-8')
         if '\n' in transfer.decode('utf-8'):
             break
     req = parse_req(data)
     resp = call_api(req, self.cache, self.persistent, self.lock)
     client_sock.send(resp.encode('utf-8'))
     self.cache.show()
     client_sock.close()
Beispiel #6
0
 def get_league(self, user):
     d = call_api(id=user.internalName, api="LOL", ext="LEAGUES")
     try:
         for entry in d['data']['summonerLeagues']['array']:
             if entry['queue'] == "RANKED_SOLO_5x5":
                 tier, division, name = entry['tier'], entry['requestorsRank'], entry['name']
                 for e in entry['entries']['array']:
                     if rawify(e['playerOrTeamName']) == user.internalName:
                         lp, wins, losses, hot = e['leaguePoints'], e['wins'], e['losses'], e['hotStreak']
                         try:
                             miniSeries = Mini_Series(e['miniSeries']['wins'], e['miniSeries']['losses'], e['miniSeries']['target'])
                         except:
                             miniSeries = None
                         break
                 score = self.get_score(tier, division, lp)
                 return League_Entry(user.displayName, tier, division, name, lp, wins, losses, hot, score, miniSeries, user.iconID)
         return League_Entry(user.displayName, None, None, None, None, None, None, False, 0, None, user.iconID)
     except:
         return League_Entry(user.displayName, None, None, None, None, None, None, False, 0, None, user.iconID)
Beispiel #7
0
    def get_status(self, user):
        d = call_api(id=user.internalName, api='LOL', ext='STATUS')

        if d is not None:
            order_dict = {'Team Ranked': '4', 'Ranked': '3', 'Normal': '2', 'Custom': '1'}
            game_types = {"RANKED_GAME": "Ranked", "PRACTICE_GAME": "Custom", "NORMAL_GAME": "Normal", "RANKED_TEAM_GAME": "Team Ranked"}
            activeGame = None
            self.game_id
            try:
                gameType = game_types[d['data']['game']['gameType']]
                order = order_dict[gameType]
                for player in d['data']['game']['playerChampionSelections']['array']:
                    if player['summonerInternalName'] == user.internalName:
                        champ_id = str(player['championId'])
                activeGame = self.get_game(d, self.game_id)
                self.game_id += 1
                spectateLink = 'lrf://spectator ' + str(d['data']['playerCredentials']['observerServerIp']) + ':' + str(d['data']['playerCredentials']['observerServerPort']) + ' ' + str(d['data']['playerCredentials']['observerEncryptionKey']) + ' ' + str(d['data']['playerCredentials']['gameId']) + ' NA1'
                return Status_Entry(user.displayName, True, self.champ_dict[champ_id], gameType, user.iconID, order, activeGame, spectateLink)
            except:
                return Status_Entry(user.displayName, False, "", "", user.iconID, "0", "", "")
        else:
            return Status_Entry(user.displayName, False, "", "", user.iconID, "0", "", "")
Beispiel #8
0
def get_darksky_weather(key, location):
    api_url = "https://api.darksky.net/forecast/{apikey}/{loc[0]:},{loc[1]:}?exclude=minutely,hourly,daily&units=si".format(
        apikey=key, loc=location)

    return utils.call_api(api_url)
Beispiel #9
0
"""
"""
from databricks_cli.clusters.api import ClusterApi
from databricks_cli.jobs.api import JobsApi
import utils


class SdkClient():
    def __init__(self, profile=None):
        client = utils.get_api_client(profile)
        self.cluster_client = ClusterApi(client)
        self.jobs_client = JobsApi(client)

    def list_clusters(self):
        return self.cluster_client.list_clusters()

    def get_cluster(self, cluster_id):
        return self.cluster_client.get_cluster(cluster_id)

    def list_jobs(self):
        return self.jobs_client.list_jobs()


if __name__ == "__main__":
    utils.call_api(SdkClient())
Beispiel #10
0
 def get_ip(self, user):
     d = call_api(id=user.internalName, api='LOL', ext='IP')
     return IP_Entry(user.displayName, d['data'], user.iconID)
Beispiel #11
0
 def get_honor(self, user):
     d = call_api(id=user.internalName, api='LOL', ext='HONOR')
     friendly, helpful, teamwork, honorable = d['data']['totals'][1], d['data']['totals'][2], d['data']['totals'][3], d['data']['totals'][4]
     total = friendly + helpful + teamwork + honorable
     return Honor_Entry(user.displayName, friendly, helpful, teamwork, honorable, total, user.iconID)
Beispiel #12
0
 def check_status(self, channelName):
     d = call_api(id=channelName, api='TWITCH', ext='ACTIVE')
     try:
         return Stream_Status(channelName, d['stream']['channel']['display_name'], d['stream']['preview']['medium'], d['stream']['game'], True)
     except:
         return None
Beispiel #13
0
 def get_stream(self, channelName):
     d = call_api(id=channelName, api="TWITCH", ext="CHANNEL")
     return ntcls.Stream_Info(channelName, d['display_name'], d['status'], d['game'], d['url'])
Beispiel #14
0
def get_currency(key, from_currency, to_currency):
    url = "https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency={fc}&to_currency={tc}&apikey={apikey}".format(
        fc=from_currency, tc=to_currency, apikey=key)

    return utils.call_api(url)
Beispiel #15
0
def get_quote(key, symbol):
    quote = "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={symbol}&apikey={apikey}".format(
        symbol=symbol, apikey=key)

    return utils.call_api(quote)