Skip to content

Commit

Permalink
strip html tags
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmandic committed Jan 20, 2023
1 parent 7f78720 commit 0220134
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/system-info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import platform
import subprocess
import time
from html.parser import HTMLParser

import accelerate
import gradio as gr
Expand Down Expand Up @@ -35,18 +36,28 @@ def get_uptime():
s = vars(shared.state)
return time.strftime('%c', time.localtime(s.get('server_start', time.time())))

class HTMLFilter(HTMLParser):
text = ""
def handle_data(self, data):
self.text += data

def get_state():
s = vars(shared.state)
flags = 'skipped ' if s.get('skipped', False) else ''
flags += 'interrupted ' if s.get('interrupted', False) else ''
flags += 'needs restart' if s.get('need_restart', False) else ''
text = s.get('textinfo', '')
if text is not None and len(text) > 0:
f = HTMLFilter()
f.feed(text)
text = os.linesep.join([s for s in f.text.splitlines() if s])
return {
'started': time.strftime('%c', time.localtime(s.get('time_start', time.time()))),
'step': f'{s.get("sampling_step", 0)} / {s.get("sampling_steps", 0)}',
'jobs': f'{s.get("job_no", 0)} / {s.get("job_count", 0)}', # pylint: disable=consider-using-f-string
'flags': flags,
'job': s.get('job', ''),
'text': s.get('textinfo', ''),
'text-info': text,
}

def get_memory():
Expand Down

0 comments on commit 0220134

Please sign in to comment.