Procházet zdrojové kódy

Assignment expressions

master
JustAnotherArchivist před 3 roky
rodič
revize
41f84376f0
1 změnil soubory, kde provedl 4 přidání a 12 odebrání
  1. +4
    -12
      irclog.py

+ 4
- 12
irclog.py Zobrazit soubor

@@ -993,22 +993,17 @@ class WebServer:
out = [] out = []
size = 0 size = 0
incomplete = False incomplete = False
while True:
buf = await proc.stdout.read(1024)
if not buf:
break
while (buf := await proc.stdout.read(1024)):
self.logger.debug(f'Request {id(request)} grep stdout: {buf!r}') self.logger.debug(f'Request {id(request)} grep stdout: {buf!r}')
if size + len(buf) > self.config['web']['search']['maxSize']: if size + len(buf) > self.config['web']['search']['maxSize']:
self.logger.warning(f'Request {id(request)} grep output exceeds max size') self.logger.warning(f'Request {id(request)} grep output exceeds max size')
bufLFPos = buf.rfind(b'\n', 0, self.config['web']['search']['maxSize'] - size)
if bufLFPos > -1:
if (bufLFPos := buf.rfind(b'\n', 0, self.config['web']['search']['maxSize'] - size)) > -1:
# There's a LF in this buffer at the right position, keep everything up to it such that the total size is <= maxSize. # There's a LF in this buffer at the right position, keep everything up to it such that the total size is <= maxSize.
out.append(buf[:bufLFPos + 1]) out.append(buf[:bufLFPos + 1])
else: else:
# Try to find the last LF in the previous buffers # Try to find the last LF in the previous buffers
for i, prevBuf in enumerate(reversed(out)): for i, prevBuf in enumerate(reversed(out)):
lfPos = prevBuf.rfind(b'\n')
if lfPos > -1:
if (lfPos := prevBuf.rfind(b'\n')) > -1:
out[i] = out[i][:lfPos + 1] out[i] = out[i][:lfPos + 1]
out = out[:i + 1] out = out[:i + 1]
break break
@@ -1024,10 +1019,7 @@ class WebServer:


async def process_stderr(): async def process_stderr():
buf = b'' buf = b''
while True:
buf = buf + (await proc.stderr.read(64))
if not buf:
break
while (buf := buf + (await proc.stderr.read(64))):
lines = buf.split(b'\n') lines = buf.split(b'\n')
buf = lines[-1] buf = lines[-1]
for line in lines[:-1]: for line in lines[:-1]:


Načítá se…
Zrušit
Uložit