165 def run(self, dry_run=False):
166 cmd =
'{} {}'.
format(self.executable, self.args)
168 cmd = self.cmd_prefix + cmd
170 cmd += self.cmd_suffix
171 if self.output_stream == self.OutputStream.NO_PRINT:
172 cmd +=
' >/dev/null 2>&1'
173 elif self.output_stream == self.OutputStream.FILE_ONLY:
174 cmd +=
' >{} 2>&1'.
format(self.get_log_file_name())
175 elif self.output_stream == self.OutputStream.FILE_AND_STDOUT:
176 cmd +=
' 2>&1 | tee {}; exit ${{PIPESTATUS[0]}}'.
format(self.get_log_file_name())
177 elif self.output_stream == self.OutputStream.STDOUT_ONLY:
180 self.log.
info(
'Running %s step using command:\n%s', self.name, cmd)
186 assert '..' not in self.workdir,
"Illegal path for workdir -- must be a subdirectory of CWD"
187 assert not self.workdir.startswith(
'/'),
"Illegal path for workdir -- no absolute paths!"
188 os.makedirs(self.workdir,exist_ok=
True)
189 os.chdir(self.workdir)
192 prmon_proc = self.__start_prmon()
194 self.result = self.__execute_with_timeout(cmd, self.timeout)
196 self.result = subprocess.call(cmd, shell=
True)
198 self.__stop_prmon(prmon_proc)
200 if self.auto_report_result:
205 and self.result != 0 \
207 and self.output_stream==self.OutputStream.FILE_ONLY:
208 self.log.
error(
'Step failure while running in CI. Printing partial log %s', self.get_log_file_name())
211 error_patterns =
'^ERROR| ERROR | FATAL |[Tt]raceback'
215 if self.executable.endswith(
'_tf.py'):
216 log =
open(self.get_log_file_name()).
read()
217 step_matches = re.findall(
'Logs for (.*) are in (.*)', log)
219 self.log.warning(
'Failed to determine sub-step log names, cannot print the full sub-step logs')
221 step_log_names = [m[1]
for m
in step_matches]
222 for step_log_name
in step_log_names:
223 if os.path.isfile(step_log_name):
224 self.log.
info(
'Printing partial sub-step log file %s', step_log_name)
227 return self.result, cmd