mirror of https://github.com/CIRCL/lookyloo
fix: make mypy happy, simplify code
parent
2ec55be573
commit
52b68fccdc
|
@ -61,21 +61,14 @@ class AsyncCapture(AbstractManager):
|
||||||
async def process_capture_queue(self) -> None:
|
async def process_capture_queue(self) -> None:
|
||||||
'''Process a query from the capture queue'''
|
'''Process a query from the capture queue'''
|
||||||
self.set_running()
|
self.set_running()
|
||||||
uuid: Optional[str]
|
uuid: Optional[str] = None
|
||||||
if isinstance(self.lacus, LacusCore):
|
if isinstance(self.lacus, LacusCore):
|
||||||
uuid = await self.lacus.consume_queue()
|
if uuid := await self.lacus.consume_queue():
|
||||||
if not uuid:
|
entries = self.lacus.get_capture(uuid, decode=True)
|
||||||
# Nothing to capture right now.
|
if entries['status'] != CaptureStatusCore.DONE:
|
||||||
self.unset_running()
|
self.logger.warning(f'The capture {uuid} is reported as not done ({entries["status"]}) when it should.')
|
||||||
return
|
self.redis.zrem('to_capture', uuid)
|
||||||
# Capture is done, doing lookyloo post processing now.
|
self.redis.delete(uuid)
|
||||||
entries = self.lacus.get_capture(uuid, decode=True)
|
|
||||||
if entries['status'] != CaptureStatusCore.DONE:
|
|
||||||
self.logger.warning(f'The capture {uuid} is reported as not done ({entries["status"]}) when it should.')
|
|
||||||
self.redis.zrem('to_capture', uuid)
|
|
||||||
self.redis.delete(uuid)
|
|
||||||
self.unset_running()
|
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
# Find a capture that is done
|
# Find a capture that is done
|
||||||
for uuid_b in self.redis.zrevrangebyscore('to_capture', 'Inf', '-Inf'):
|
for uuid_b in self.redis.zrevrangebyscore('to_capture', 'Inf', '-Inf'):
|
||||||
|
@ -85,10 +78,10 @@ class AsyncCapture(AbstractManager):
|
||||||
entries = self.lacus.get_capture(uuid)
|
entries = self.lacus.get_capture(uuid)
|
||||||
if entries['status'] == CaptureStatusPy.DONE:
|
if entries['status'] == CaptureStatusPy.DONE:
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
# Nothing to capture right now.
|
if uuid is None:
|
||||||
self.unset_running()
|
self.unset_running()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.redis.sadd('ongoing', uuid)
|
self.redis.sadd('ongoing', uuid)
|
||||||
queue: Optional[bytes] = self.redis.getdel(f'{uuid}_mgmt')
|
queue: Optional[bytes] = self.redis.getdel(f'{uuid}_mgmt')
|
||||||
|
|
Loading…
Reference in New Issue