Skip to content

Commit e0809eb

Browse files
authored
Support reading notes from services (#590)
* Support reading notes from services * Avoid loop through stdout if reading not configured * Add log-stdout and log-stderr to schema schecker
1 parent db1fcf3 commit e0809eb

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/schema_checker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ def check_usage_scenario(self, usage_scenario):
103103
Optional("volumes"): self.single_or_list(str),
104104
Optional("folder-destination"):str,
105105
Optional("cmd"): str,
106+
Optional("log-stdout"): bool,
107+
Optional("log-stderr"): bool,
108+
Optional("read-notes-stdout"): bool,
109+
Optional("read-sci-stdout"): bool,
106110
}
107111
},
108112

@@ -115,6 +119,7 @@ def check_usage_scenario(self, usage_scenario):
115119
Optional("detach"): bool,
116120
Optional("note"): str,
117121
Optional("read-notes-stdout"): bool,
122+
Optional("read-sci-stdout"): bool,
118123
Optional("ignore-errors"): bool,
119124
Optional("shell"): str,
120125
Optional("log-stdout"): bool,

runner.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ def setup_services(self):
880880
'name': container_name,
881881
'log-stdout': service.get('log-stdout', False),
882882
'log-stderr': service.get('log-stderr', True),
883+
'read-notes-stdout': service.get('read-notes-stdout', False),
883884
'read-sci-stdout': service.get('read-sci-stdout', False),
884885
}
885886

@@ -1194,9 +1195,8 @@ def read_container_logs(self):
11941195
if container_info['log-stderr'] is True:
11951196
stderr_behaviour = subprocess.PIPE
11961197

1197-
11981198
log = subprocess.run(
1199-
['docker', 'logs', '-t', container_id],
1199+
['docker', 'logs', container_id],
12001200
check=True,
12011201
encoding='UTF-8',
12021202
stdout=stdout_behaviour,
@@ -1205,10 +1205,16 @@ def read_container_logs(self):
12051205

12061206
if log.stdout:
12071207
self.add_to_log(container_id, f"stdout: {log.stdout}")
1208-
if container_info['read-sci-stdout']:
1208+
1209+
if container_info['read-notes-stdout'] or container_info['read-sci-stdout']:
12091210
for line in log.stdout.splitlines():
1210-
if match := re.findall(r'GMT_SCI_R=(\d+)', line):
1211-
self._sci['R'] += int(match[0])
1211+
if container_info['read-notes-stdout']:
1212+
if note := self.__notes_helper.parse_note(line):
1213+
self.__notes_helper.add_note({'note': note[1], 'detail_name': container_info['name'], 'timestamp': note[0]})
1214+
1215+
if container_info['read-sci-stdout']:
1216+
if match := re.findall(r'GMT_SCI_R=(\d+)', line):
1217+
self._sci['R'] += int(match[0])
12121218

12131219
if log.stderr:
12141220
self.add_to_log(container_id, f"stderr: {log.stderr}")

0 commit comments

Comments
 (0)