Skip to content

Commit

Permalink
Set aiohttp to respect proxy vars like requests/urllib3
Browse files Browse the repository at this point in the history
- Works but has a bug at the moment of printing that ~/.netrc is missing
https://pastebin.com/tSYtrvjr
- Tracked here: aio-libs/aiohttp#3298
- Fixes #73
  • Loading branch information
cooperlees committed Oct 30, 2018
1 parent 5739e83 commit 9a524b2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/bandersnatch/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ async def verify(
logger.debug(f"Not trying to sync package as {json_full_path} does not exist")
return

with json_full_path.open("r") as jfp:
pkg = json.load(jfp)
try:
with json_full_path.open("r") as jfp:
pkg = json.load(jfp)
except json.decoder.JSONDecodeError as jde:
logger.error(f"Failed to load {json_full_path}: {jde} - skipping ...")
return

for release_version in pkg[releases_key]:
for jpkg in pkg[releases_key][release_version]:
Expand Down Expand Up @@ -132,7 +136,7 @@ async def url_fetch(url, file_path, executor, chunk_size=65536, timeout=60):
skip_headers = {"User-Agent"}

async with aiohttp.ClientSession(
headers=custom_headers, skip_auto_headers=skip_headers
headers=custom_headers, skip_auto_headers=skip_headers, trust_env=True
) as session:
async with session.get(url, timeout=timeout) as response:
if response.status == 200:
Expand Down

0 comments on commit 9a524b2

Please sign in to comment.