mirror of
https://github.com/Jylpah/blitz-tools.git
synced 2026-10-24 03:29:54 +02:00
Merge pull request #19 from Jylpah/stable-fix
Bug Fix: add _id to replays read from filesystem
This commit is contained in:
2 files changed
+18
-2
No files matched your search
@@ -1960,7 +1960,7 @@ async def mk_replayQ(queue : asyncio.Queue, args : argparse.Namespace, db : moto
|
|||||||
if not line: break
|
if not line: break
|
||||||
|
|
||||||
if (p_replayfile.match(line) != None):
|
if (p_replayfile.match(line) != None):
|
||||||
replay_json = await bu.open_JSON(line, wi.chk_JSON_replay)
|
replay_json = await bu.open_JSON(line, wi.chk_JSON_replay)
|
||||||
await queue.put(await mk_readerQ_item(replay_json, line))
|
await queue.put(await mk_readerQ_item(replay_json, line))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
bu.error(exception=err)
|
bu.error(exception=err)
|
||||||
@@ -1993,7 +1993,13 @@ async def mk_replayQ(queue : asyncio.Queue, args : argparse.Namespace, db : moto
|
|||||||
async def mk_readerQ_item(replay_json, filename : str = None) -> list:
|
async def mk_readerQ_item(replay_json, filename : str = None) -> list:
|
||||||
"""Make an item to replay queue"""
|
"""Make an item to replay queue"""
|
||||||
global REPLAY_N
|
global REPLAY_N
|
||||||
REPLAY_N +=1
|
REPLAY_N +=1
|
||||||
|
try:
|
||||||
|
if not '_id' in replay_json:
|
||||||
|
id = wi.read_replay_id(replay_json)
|
||||||
|
replay_json['_id'] = id
|
||||||
|
except Exception as err:
|
||||||
|
bu.error(exception=err)
|
||||||
if filename == None:
|
if filename == None:
|
||||||
return [replay_json, REPLAY_N, '' ]
|
return [replay_json, REPLAY_N, '' ]
|
||||||
elif RE_SRC_IS_DB.match(filename) != None:
|
elif RE_SRC_IS_DB.match(filename) != None:
|
||||||
|
|||||||
@@ -1747,6 +1747,16 @@ class WoTinspector:
|
|||||||
return url.rsplit('/', 1)[-1]
|
return url.rsplit('/', 1)[-1]
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def read_replay_id(cls, json_replay):
|
||||||
|
"""Read replay_id from replay JSON file"""
|
||||||
|
try:
|
||||||
|
url = json_replay['data']['view_url']
|
||||||
|
return cls.get_replay_id(url)
|
||||||
|
except Exception as err:
|
||||||
|
error(exception=err)
|
||||||
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def chk_JSON_replay(cls, json_resp):
|
def chk_JSON_replay(cls, json_resp):
|
||||||
""""Check String for being a valid JSON file"""
|
""""Check String for being a valid JSON file"""
|
||||||
|
|||||||
Reference in new issue
Block a user