mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 15:57:14 +03:00
companion: Rename Auth.session to requests_session
So as to not confuse with companion.session.
This commit is contained in:
parent
bc29891cc1
commit
6968cd6c69
@ -247,10 +247,10 @@ from edmc_data import DEBUG_WEBSERVER_HOST, DEBUG_WEBSERVER_PORT
|
||||
|
||||
TARGET_URL = 'https://www.edsm.net/api-journal-v1'
|
||||
if 'edsm' in debug_senders:
|
||||
TARGET_URL = f'http://{DEBUG_WEBSERVER_HOST}:{DEBUG_WEBSERVER_PORT}/edsm'
|
||||
TARGET_URL = f'http://{DEBUG_WEBSERVER_HOST}:{DEBUG_WEBSERVER_PORT}/edsm'
|
||||
|
||||
...
|
||||
r = this.session.post(TARGET_URL, data=data, timeout=_TIMEOUT)
|
||||
r = this.requests_session.post(TARGET_URL, data=data, timeout=_TIMEOUT)
|
||||
```
|
||||
|
||||
Be sure to set a URL path in the `TARGET_URL` that denotes where the data
|
||||
|
14
companion.py
14
companion.py
@ -295,15 +295,15 @@ class Auth(object):
|
||||
|
||||
def __init__(self, cmdr: str) -> None:
|
||||
self.cmdr: str = cmdr
|
||||
self.session = requests.Session()
|
||||
self.session.headers['User-Agent'] = USER_AGENT
|
||||
self.requests_session = requests.Session()
|
||||
self.requests_session.headers['User-Agent'] = USER_AGENT
|
||||
self.verifier: Union[bytes, None] = None
|
||||
self.state: Union[str, None] = None
|
||||
|
||||
def __del__(self) -> None:
|
||||
"""Ensure our Session is closed if we're being deleted."""
|
||||
if self.session:
|
||||
self.session.close()
|
||||
if self.requests_session:
|
||||
self.requests_session.close()
|
||||
|
||||
def refresh(self) -> Optional[str]:
|
||||
"""
|
||||
@ -334,7 +334,7 @@ class Auth(object):
|
||||
|
||||
logger.debug('Attempting refresh with Frontier...')
|
||||
try:
|
||||
r = self.session.post(
|
||||
r = self.requests_session.post(
|
||||
FRONTIER_AUTH_SERVER + self.FRONTIER_AUTH_PATH_TOKEN,
|
||||
data=data,
|
||||
timeout=auth_timeout
|
||||
@ -422,7 +422,7 @@ class Auth(object):
|
||||
# requests_log.setLevel(logging.DEBUG)
|
||||
# requests_log.propagate = True
|
||||
|
||||
r = self.session.post(
|
||||
r = self.requests_session.post(
|
||||
FRONTIER_AUTH_SERVER + self.FRONTIER_AUTH_PATH_TOKEN,
|
||||
data=request_data,
|
||||
timeout=auth_timeout
|
||||
@ -430,7 +430,7 @@ class Auth(object):
|
||||
data_token = r.json()
|
||||
if r.status_code == requests.codes.ok:
|
||||
# Now we need to /decode the token to check the customer_id against FID
|
||||
r = self.session.get(
|
||||
r = self.requests_session.get(
|
||||
FRONTIER_AUTH_SERVER + self.FRONTIER_AUTH_PATH_DECODE,
|
||||
headers={
|
||||
'Authorization': f'Bearer {data_token.get("access_token", "")}',
|
||||
|
Loading…
x
Reference in New Issue
Block a user