Skip to content

Commit 9bdac9f

Browse files
author
Michael Hammann
committed
feature: added support for matching regex output even if asci escape sequences are used on the output
1 parent 59c7f64 commit 9bdac9f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

supervisor/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ def get(section, opt, *args, **kwargs):
935935
runningregex = get(section, 'runningregex', None)
936936
if runningregex:
937937
try:
938-
runningregex = re.compile(runningregex)
938+
runningregex = re.compile(r'.*'+ runningregex)
939939
except Exception as e:
940940
raise ValueError(
941941
f"program section {section} has invalid runningregex value. Error {e}")

supervisor/process.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import shlex
66
import time
77
import traceback
8+
import re
89

910
from supervisor.compat import maxint
1011
from supervisor.compat import as_bytes
@@ -698,6 +699,10 @@ def transition(self):
698699

699700
from supervisor.options import readFile
700701
str = as_string(readFile(logfile, 0, 0))
702+
703+
# delete ascii escape sequence and newlines with regular expression
704+
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]|\n')
705+
str = ansi_escape.sub('', str)
701706

702707
if self.config.runningregex.match(str):
703708
# STARTING -> RUNNING if the proc has started

0 commit comments

Comments
 (0)