1# -*- coding: utf-8 -*- 2 3""" 4This module allows to consult execution output clusters, in parallel case 5only output of processor 0 is shown. 6A regular expression could be used to search only matching lines of output. 7 8These asrun customizations are called through (in asrun configuration file) : 9 10 schema_tail_exec : plugins.tail_slurm.tail 11 12""" 13 14from asrun.core import magic 15from asrun.common_func import flash_filename 16from asrun.job import Func_actu 17 18 19def tail(run, jobid, jobname, mode, nbline, expression=None): 20 """Custom the tail function by reading the output in flash directory""" 21 # keep output of proc0 only 22 etat, diag, node, tcpu, wrk, queue = Func_actu(run, jobid, jobname, mode) 23 jret = 0 24 s_out = '' 25 if etat == 'RUN': 26 cmd = "egrep -v -- '^\[[1-9][0-9]*\]' {fich}" 27 if expression is None or expression.strip() == "": 28 cmd += " | tail -{nbline}" 29 else: 30 cmd += " | egrep -- '{expression}'" 31 fich = flash_filename("flasheur", jobname, jobid, "output") 32 if run.Exists(fich): 33 jret, s_out = run.Shell(cmd.format(**locals()), mach="") 34 return etat, diag, s_out 35