derek-thomas HF staff commited on
Commit
d800d71
1 Parent(s): ef89b19

Adding better console handling

Browse files
Files changed (1) hide show
  1. src/display/log_visualizer.py +3 -2
src/display/log_visualizer.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from pathlib import Path
2
 
3
  from bs4 import BeautifulSoup
@@ -12,7 +13,6 @@ proj_dir = Path(__name__).parent
12
 
13
 
14
  def log_file_to_html_string():
15
- console = Console(record=True, width=150, style="#272822")
16
  with open(log_file, "rt") as f:
17
  # Seek to the end of the file minus 300 lines
18
  # Read the last 300 lines of the file
@@ -23,7 +23,8 @@ def log_file_to_html_string():
23
  output = "".join(reversed(lines))
24
  syntax = Syntax(output, "python", theme="monokai", word_wrap=True)
25
 
26
- console.print(syntax);
 
27
  html_content = console.export_html(inline_styles=True)
28
 
29
  # Parse the HTML content using BeautifulSoup
 
1
+ from io import StringIO
2
  from pathlib import Path
3
 
4
  from bs4 import BeautifulSoup
 
13
 
14
 
15
  def log_file_to_html_string():
 
16
  with open(log_file, "rt") as f:
17
  # Seek to the end of the file minus 300 lines
18
  # Read the last 300 lines of the file
 
23
  output = "".join(reversed(lines))
24
  syntax = Syntax(output, "python", theme="monokai", word_wrap=True)
25
 
26
+ console = Console(record=True, width=150, style="#272822", file=StringIO())
27
+ console.print(syntax)
28
  html_content = console.export_html(inline_styles=True)
29
 
30
  # Parse the HTML content using BeautifulSoup