-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_success_check.py
executable file
·66 lines (49 loc) · 1.54 KB
/
run_success_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python2
"""
COSMO TECHNICAL TESTSUITE
This script checks whether the standard output of the COSMO simulation
contains the words "CLEAN UP" which is indicative of a fully successful
simulation
"""
# built-in modules
import os, re, sys
# private modules
sys.path.append("./tools") # this is the generic folder for subroutines
sys.path.append('../checktools/tools')
from ts_utilities import read_environ, dir_path
# information
__author__ = "Nicolo Lardelli, Oliver Fuhrer"
__copyright__ = "Copyright 2012, COSMO Consortium"
__license__ = "GPL"
__version__ = "1.0"
__date__ = "Mon Oct 8 15:37:57 CEST 2012"
__email__ = "cosmo-wg6@cosmo.org"
__maintainer__ = "xavier.lapillonne@meteoswiss.ch"
def check():
# initialize status
status = 0 # MATCH
# get name of myself
myname = os.path.basename(__file__)
header = myname+': '
# get environment variables
env = read_environ()
verbose = int(env['VERBOSE'])
rundir = env['RUNDIR']
logfile = dir_path(rundir) + env['LOGFILE']
if verbose>2:
print header + 'checking presence of CLEAN UP cleanup line in '+logfile
try:
file = open(logfile,'r')
pattern = '(.*)^(.*)CLEAN(\s)UP(.*)'
result = 30 # CRASH
for text in file:
if re.match(pattern, text):
result = 0 # MATCH
file.close()
except:
if verbose:
print header+'failed to open '+logfile
result = 30 # CRASH
return result
if __name__ == "__main__":
sys.exit(check())