def _client(self): # Lazily evaluated, cached esipy client instance return esipy.EsiClient( retry_requests=True, headers=self.headers, raw_body_only=False # most of the time we'll parse )
def __init__(self): #self.cache = FileCache(path='./esicache/') self.redis_client = redis.Redis(host='localhost', port=6379, db=1) self.cache = RedisCache(self.redis_client) self.esi_app = esipy.App.create(url='https://esi.tech.ccp.is/latest/swagger.json?datasource=tranquility') self.esi_client = esipy.EsiClient( headers={'User-Agent': config.email}, raw_body_only=True, cache=self.cache )
def __init__(self, bot: commands.Bot): super(KillmailPoster, self).__init__(bot) self.logger = get_logger(__name__, bot) self.bot = bot self.config_table = KeyValueTable(self.bot.tdb, "killmails.config") self.channel = self.bot.get_channel(self.config_table["channel"]) self.esi_client = esipy.EsiClient(retry_requests=True) self.rigs_emoji = None for emoji in self.channel.server.emojis: if str(emoji) == self.config_table["rigs_emoji"]: self.rigs_emoji = emoji break self.relevancy_table = self.bot.tdb.table("killmails.relevancies") self.relevancy = tinydb.Query()
def create_client(self): client = esipy.EsiClient( retry_requests=True, headers={'User-Agent': 'Owned by Sajuukthanatoskhar'}, security=self.security # Might be a problem ) try: import dotenv if self.mw_refresh_key == "": webbrowser.open(self.security.get_auth_uri( state='logging_in_state', scopes=self.scope), new=1) access_token = input( "Access token please (copypaste from the code section") refresh_key = self.security.auth( str(access_token))['refresh_token'] dotenv.set_key(self.dot_env_f, "env_refresh_key", refresh_key) else: self.refresh_token_key() except UnboundLocalError: pass return client
import esipy import requests import time # Set up network access client = esipy.EsiClient( transport_adapter=requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100, max_retries=10, pool_block=False), headers={ 'User-Agent': 'EVE economy AI playground ([email protected])' }) app = esipy.EsiApp().get_latest_swagger def check_retry(response): if response.status // 100 != 5 and response.status != 429: if response.status // 100 != 2: raise ValueError('Request returned status {}'.format( response.status)) return False return True def request(req, delay=1): while True: response = client.request(req)
def get_client(self, security=None): return esipy.EsiClient(security=security, headers={'User-Agent': settings.ESI_USER_AGENT})
def _client(self): return esipy.EsiClient(retry_requests=True, headers={'User-Agent': USER_AGENT_STRING}, raw_body_only=False, security=self._security)
import click import esipy # On loading the module initialize the ESI Swagger App, Client and Security if os.path.isfile('app.pickle'): with open('app.pickle', 'rb') as f: app = pickle.load(f) else: app = esipy.App.create(url='https://esi.tech.ccp.is/latest/swagger.json?datasource=tranquility') with open('app.pickle', 'wb') as f: pickle.dump(app, f) security = esipy.EsiSecurity(app=app, redirect_uri='http://localhost:7070/callback', client_id='ca73ab1ab8a949518d8e9d35ea46d2d2', secret_key='crLG9e6cQ7rYlDxgVZKEfH0yw2x3VFkUBPdy2MYb', headers={'User-Agent': 'EVE CLI by Leonty Alkaev'}) client = esipy.EsiClient(security=security, headers={'User-Agent': 'EVE CLI by Leonty Alkaev'}) # Configure the callback server # TODO switch to flask again and use the shutdown function, see http://flask.pocoo.org/snippets/67/ cherrypy.log.screen = None cherrypy.log.logger_root = None cherrypy.config.update({'server.socket_port': 7070}) cherrypy.config.update({'server.shutdown_timeout': 1}) cherrypy.config.update({'engine.autoreload.on': False}) class Authenticator(object): """Provide a callback to the authentication request and store the provided authentication data. """