1 """
2 Class that implements the common functionality for treatment of the standard output
3 """
4
5 from optparse import OptionGroup
6 from os import path
7
9 """ The class that defines options for standard output
10 """
11
13 grp=OptionGroup(self.parser,
14 "Standard Output",
15 "Treatment of the standard output that is captured from the OpenFOAM-application")
16 grp.add_option("--progress",
17 action="store_true",
18 default=False,
19 dest="progress",
20 help="Only prints the progress of the simulation, but swallows all the other output")
21 grp.add_option("--silent",
22 action="store_true",
23 default=False,
24 dest="silent",
25 help="Do not print any output")
26 grp.add_option("--logname",
27 dest="logname",
28 default=logname,
29 help="Name of the logfile")
30 grp.add_option("--compress",
31 action="store_true",
32 dest="compress",
33 default=False,
34 help="Compress the logfile into a gzip file. Possible loss of data if the run fails")
35 grp.add_option("--no-log",
36 action="store_true",
37 dest="noLog",
38 default=False,
39 help="Do not output a log-file")
40 grp.add_option("--log-tail",
41 action="store",
42 dest="logTail",
43 default=None,
44 type="int",
45 help="Only write the last N lines to the logfile. Too small values might cause performance problems")
46
47 self.parser.add_option_group(grp)
48
49 inf=OptionGroup(self.parser,
50 "Run Info",
51 "Additional information about the run")
52 inf.add_option("--remark",
53 dest="remark",
54 default=None,
55 help="Text string with a remark about the run")
56 inf.add_option("--job-id",
57 dest="jobId",
58 default=None,
59 help="Text string with the job-ID of the queuing system (usually unused)")
60 self.parser.add_option_group(inf)
61
62 - def setLogname(self,
63 default="PyFoamRunner",
64 useApplication=True):
65 """Builds a logfile-name
66 @param default: Default value if no prefix for the logfile-has been defined
67 @param useApplication: append the name of the application to the prefix"""
68
69 if self.opts.logname==None:
70 self.opts.logname=default
71 if useApplication:
72 self.opts.logname+="."+path.basename(self.parser.getArgs()[0])
73