mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 00:46:05 +00:00
fix(admin): the Logs download survives any row and stops at a size it can build
- A failed login writes the name it was tried with, as typed: a control character in it made every download holding that row fail, as the workbook cannot hold one. Workbooks now write it as \x01; the VM report shares the code. - A download held every matching row in memory: it now takes the newest 100000, and its About sheet says when the search should be narrowed.
This commit is contained in:
parent
0b5eb990ed
commit
5ef3437291
3 changed files with 28 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
|||
from io import BytesIO
|
||||
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE
|
||||
from openpyxl.styles import Font
|
||||
from openpyxl.utils import get_column_letter
|
||||
|
||||
|
|
@ -17,7 +18,9 @@ def workbook(title, header, rows, notes_title, notes):
|
|||
sheet = book.active
|
||||
sheet.title = title
|
||||
for values in [header, *rows]:
|
||||
sheet.append(values)
|
||||
# a control character (a name typed at a failed login) cannot be in the file: written as \x01
|
||||
sheet.append([ILLEGAL_CHARACTERS_RE.sub(lambda m: f"\\x{ord(m.group()):02x}", value)
|
||||
if isinstance(value, str) else value for value in values])
|
||||
for row in sheet.iter_rows():
|
||||
for cell in row:
|
||||
if isinstance(cell.value, str):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue