@@ -122,21 +122,35 @@ def handle_casting_failure(casting_state: str, log_file_paths: List[str]):
122
122
def extract_value_from_string (line : str , value_name : str , casting_state : str , log_paths ) -> str :
123
123
"""Extract and return value from given input string.
124
124
125
- The string is expected to be in the following format as it is received
126
- from the Linux tv-casting-app output:
127
- \x1b [0;34m[1715206773402] [20056:2842184] [DMG] Cluster = 0x506,\x1b [0m
128
- The substring to be extracted here is '0x506'.
129
- Or:
130
- \x1b [0;32m[1714582264602] [77989:2286038] [SVR] Discovered Commissioner #0\x1b [0m
131
- The integer value to be extracted here is '0'.
132
- Or:
133
- \x1b [0;34m[1713741926895] [7276:9521344] [DIS] Vendor ID: 65521\x1b [0m
134
- The integer value to be extracted here is '65521'.
135
- Or:
136
- \x1b [0;34m[1714583616179] [7029:2386956] [SVR] device Name: Test TV casting app\x1b [0m
137
- The substring to be extracted here is 'Test TV casting app'.
125
+ Some input string examples as they are received from the Linux tv-casting-app and tv-app output:
126
+ 1. On 'darwin' machines:
127
+ \x1b [0;34m[1715206773402] [20056:2842184] [DMG] Cluster = 0x506,\x1b [0m
128
+ The substring to be extracted here is '0x506'.
129
+
130
+ Or:
131
+ \x1b [0;32m[1714582264602] [77989:2286038] [SVR] Discovered Commissioner #0\x1b [0m
132
+ The integer value to be extracted here is '0'.
133
+
134
+ Or:
135
+ \x1b [0;34m[1713741926895] [7276:9521344] [DIS] Vendor ID: 65521\x1b [0m
136
+ The integer value to be extracted here is '65521'.
137
+
138
+ Or:
139
+ \x1b [0;34m[1714583616179] [7029:2386956] [SVR] device Name: Test TV casting app\x1b [0m
140
+ The substring to be extracted here is 'Test TV casting app'.
141
+
142
+ 2. On 'linux' machines:
143
+ [1716224960.316809][6906:6906] CHIP:DMG: \t \t \t \t \t Cluster = 0x506,\n
144
+ [1716224958.576320][6906:6906] CHIP:SVR: Discovered Commissioner #0
145
+ [1716224958.576407][6906:6906] CHIP:DIS: \t Vendor ID: 65521\n
146
+ [1716224959.580746][6906:6906] CHIP:SVR: \t device Name: Test TV casting app\n
138
147
"""
139
- log_line_pattern = r'\x1b\[0;\d+m\[\d+\] \[\d+:\d+\] \[[A-Z]{1,3}\] (.+?)\x1b\[0m'
148
+ log_line_pattern = ''
149
+ if sys .platform == 'darwin' :
150
+ log_line_pattern = r'\x1b\[0;\d+m\[\d+\] \[\d+:\d+\] \[[A-Z]{1,3}\] (.+)\x1b\[0m'
151
+ elif sys .platform == 'linux' :
152
+ log_line_pattern = r'\[\d+\.\d+\]\[\d+:\d+\] [A-Z]{1,4}:[A-Z]{1,3}: (.+)'
153
+
140
154
log_line_match = re .search (log_line_pattern , line )
141
155
142
156
if log_line_match :
0 commit comments