added remove ansi escape
This commit is contained in:
10
collect.py
10
collect.py
@@ -100,6 +100,12 @@ def convert_to_megabytes(data_size):
|
||||
return int(size * unit_map[unit])
|
||||
|
||||
|
||||
def remove_ansi_escape(text):
|
||||
"""Removes ANSI escape sequences from a string."""
|
||||
ansi_escape = re.compile(r"\x1B(?:[@-Z\\^[\]m])+")
|
||||
return ansi_escape.sub("", text)
|
||||
|
||||
|
||||
def scaleMemstat():
|
||||
command = ["top", "-n", "1"]
|
||||
|
||||
@@ -108,8 +114,8 @@ def scaleMemstat():
|
||||
|
||||
if collect:
|
||||
mem = re.search("Mem :.*", collect).group()
|
||||
mem = re.sub("^.*Mem..", "", mem.strip())
|
||||
mem = re.sub("[total|free|used|buff.cache|,]", "", mem.strip()).split()
|
||||
mem = re.sub("Mem..", "", mem.strip())
|
||||
mem = re.sub("[total|free|used|buff|cache|,|/]", "", mem.strip())
|
||||
|
||||
breakpoint()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user