Skip to content

Proposed change of wait_for using regex #1762

@panicking

Description

@panicking

Is this consider an acceptable change?

diff --git a/labgrid/driver/commandmixin.py b/labgrid/driver/commandmixin.py
index 4c187681..ccad82f3 100644
--- a/labgrid/driver/commandmixin.py
+++ b/labgrid/driver/commandmixin.py
@@ -1,3 +1,5 @@
+import re
+
 from time import sleep
 
 from ..util import Timeout
@@ -23,12 +25,12 @@ class CommandMixin:
 
         Args:
             cmd (str): command to run on the shell
-            pattern (str): pattern as a string to look for in the output
+            pattern (str): regex pattern string to look for in the output
             timeout (float): timeout for the pattern detection
             sleepduration (int): sleep time between the runs of the cmd
         """
         timeout = Timeout(timeout)
-        while not any(pattern in s for s in self.run_check(cmd)) and not timeout.expired:
+        while not any(re.search(pattern, s) for s in self.run_check(cmd)) and not timeout.expired:
             sleep(sleepduration)
         if timeout.expired:
             raise ExecutionError("Wait timeout expired")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions