mirror of
https://github.com/Jylpah/blitz-tools.git
synced 2026-10-24 19:49:52 +02:00
get_url_JSON(): fix handling of url = None
This commit is contained in:
1 parent
a349d8ebea
commit
8b3f6d0262
2 files changed
+4
-5
No files matched your search
@@ -335,7 +335,7 @@ class BattleRecordCategory():
|
|||||||
def get_headers(self):
|
def get_headers(self):
|
||||||
try:
|
try:
|
||||||
headers = [ RESULT_CAT_HEADER_FRMT.format(result_categories[self.category_name][0]) ]
|
headers = [ RESULT_CAT_HEADER_FRMT.format(result_categories[self.category_name][0]) ]
|
||||||
for field in result_fields.keys():
|
for field in result_display_fields:
|
||||||
print_format = '{:^' + str(result_fields[field][2]) + 's}'
|
print_format = '{:^' + str(result_fields[field][2]) + 's}'
|
||||||
headers.append(print_format.format(result_fields[field][0]))
|
headers.append(print_format.format(result_fields[field][0]))
|
||||||
return headers
|
return headers
|
||||||
|
|||||||
+3
-4
@@ -252,11 +252,13 @@ async def open_JSON(filename: str, chk_JSON_func = None) -> dict:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
async def get_url_JSON(session: aiohttp.ClientSession, url, chk_JSON_func = None, max_tries = MAX_RETRIES) -> dict:
|
async def get_url_JSON(session: aiohttp.ClientSession, url: str, chk_JSON_func = None, max_tries = MAX_RETRIES) -> dict:
|
||||||
"""Retrieve (GET) an URL and return JSON object"""
|
"""Retrieve (GET) an URL and return JSON object"""
|
||||||
if session == None:
|
if session == None:
|
||||||
error('Session must be initialized first')
|
error('Session must be initialized first')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
if url == None:
|
||||||
|
return None
|
||||||
|
|
||||||
## To avoid excessive use of servers
|
## To avoid excessive use of servers
|
||||||
for retry in range(1,max_tries+1):
|
for retry in range(1,max_tries+1):
|
||||||
@@ -830,10 +832,7 @@ class WG:
|
|||||||
|
|
||||||
async def get_player_tank_stats(self, account_id: int, tank_ids = [], fields = [], cache=True) -> dict:
|
async def get_player_tank_stats(self, account_id: int, tank_ids = [], fields = [], cache=True) -> dict:
|
||||||
"""Get player's stats (WR, # of battles) in a tank or all tanks (empty tank_ids[])"""
|
"""Get player's stats (WR, # of battles) in a tank or all tanks (empty tank_ids[])"""
|
||||||
# debug('Started')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
#debug('account_id: ' + str(account_id) + ' TankID: ' + ','.join([ str(id) for id in tank_ids]))
|
|
||||||
stats = None
|
stats = None
|
||||||
|
|
||||||
# try cached stats first:
|
# try cached stats first:
|
||||||
|
|||||||
Reference in new issue
Block a user