/usr/lib/python2.7/dist-packages/code_saturne/autovnv/TexMaker.py is in code-saturne-data 4.3.3+repack-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | # -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# This file is part of Code_Saturne, a general-purpose CFD tool.
#
# Copyright (C) 1998-2016 EDF S.A.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Standard modules import
#-------------------------------------------------------------------------------
import os
#-------------------------------------------------------------------------------
# Application modules import
#-------------------------------------------------------------------------------
from autovnv.Command import run_autovnv_command
#-------------------------------------------------------------------------------
class TexWriter(object):
"""
"""
def __init__(self, dest, filename, log):
self.__dest = dest
self.__filename = os.path.join(self.__dest, filename)
self.__doc = []
self.__log = log
def rawLine(self, line):
self.__doc.append(line)
def appendLine(self, line):
line = line.replace("_", "\_")
self.__doc.append("%s \n" % (line))
def addFigure(self, g):
self.__doc.append("\\begin{center}\n")
self.__doc.append("\\includegraphics[width=0.99\\textwidth]{%s}\n" % g)
self.__doc.append("\\end{center}\n")
def addInput(self, filename):
self.appendLine("\n\\begin{verbatim}")
f = open(filename)
self.rawLine(f.read())
f.close()
self.appendLine("\\end{verbatim}\n")
def addTexInput(self, filename):
f = open(filename)
self.rawLine(f.read())
f.close()
def tabCreate(self, columns):
assert type(columns) == list
self.__doc.append("\\begin{center}\n")
s = "l|"*len(columns)
self.__doc.append("\\begin{longtable}{|%s}\n" % s)
self.__doc.append("\hline\n")
for i in range(len(columns)):
if i != len(columns)-1:
self.__doc.append("\\textbf{%s} &" % (columns[i]))
else:
self.__doc.append("\\textbf{%s} \\\ \n" % (columns[i]))
self.__doc.append("\hline\n")
self.__doc.append("\hline\n")
def tabWrite(self, columns):
assert type(columns) == list
for i in range(len(columns)):
if columns[i] == "OK":
columns[i] = "\\textcolor{green}{OK}"
elif columns[i] == "KO":
columns[i] = "\\textcolor{red}{KO}"
elif columns[i] == None:
columns[i] = "\\textit{default}"
if i != len(columns)-1:
self.__doc.append("%s &" % (columns[i]))
else:
self.__doc.append("%s \\\ \n" % (columns[i]))
self.__doc.append("\hline\n")
def tabClose(self):
self.__doc.append("\\end{longtable}\n")
self.__doc.append("\\end{center}\n")
def write(self):
# header
head = []
head.append("\\documentclass[a4paper, 10pt]{article}\n")
head.append("\\usepackage[latin1]{inputenc}\n")
head.append("\\usepackage[T1]{fontenc}\n")
head.append("\\usepackage[normalem]{ulem}\n")
head.append("\\usepackage[french]{babel}\n")
head.append("\\usepackage{verbatim}\n")
head.append("\\usepackage{color}\n")
head.append("\\usepackage{longtable}\n")
head.append("\\usepackage{listings}\n")
head.append("\\usepackage{ifpdf}\n")
head.append("\\ifpdf\n")
head.append("\\pdfcompresslevel=9\n")
head.append("\\usepackage[pdftex]{graphicx}\n")
head.append("\\DeclareGraphicsExtensions{.png,.pdf,.jpg}\n")
head.append("\\else\n")
head.append("\\usepackage{graphicx}\n")
head.append("\\fi\n")
head.append("\\setlength{\\voffset}{0pt}")
head.append("\\setlength{\\topmargin}{0pt}")
head.append("\\addtolength{\\topmargin}{-13mm}")
head.append("\\setlength{\\headheight}{15mm}")
head.append("\\setlength{\\headsep}{6mm}")
head.append("\\setlength{\\textheight}{233mm}")
head.append("\\setlength{\\footskip}{15mm}")
head.append("\\setlength{\\hoffset}{0pt}")
head.append("\\setlength{\\evensidemargin}{0mm}")
head.append("\\setlength{\\oddsidemargin}{0mm}")
head.append("\\setlength{\\textwidth}{162mm}")
head.append("\\setlength{\\parindent}{0mm}")
head.append("\\setlength{\\parskip}{6pt}")
head.append("\\setlength{\\tabcolsep}{1mm}")
head.append("\\begin{document}\n")
# end
tail = []
tail.append("\\end{document} \n")
# write
f = open(self.__filename + ".tex", mode='w')
f.writelines(head + self.__doc + tail)
f.close()
def make_pdf(self):
"""
Buld the pdf file, and clean the temporary files.
"""
cmd = "pdflatex " + self.__filename + ".tex"
r, t = run_autovnv_command(cmd, self.__log)
for suffixe in ["tex", "log", "aux"]:
f = self.__filename + "." + suffixe
if os.path.isfile(f):
os.remove(self.__filename + "." + suffixe)
return self.__filename + ".pdf"
#-------------------------------------------------------------------------------
class Report1(TexWriter):
"""
Global report.
"""
def __init__(self, dest, label, log, report, xml):
TexWriter.__init__(self, dest, label, log)
self.appendLine("\\section{Summary}")
self.tabCreate(["Study / Case", "Compilation", "Run", "Time (s)", "Difference"])
self.xml = xml
self.report = report
def add_row(self, studyLabel, caseLabel, is_compil, is_run, is_time, is_compare, is_diff):
if is_compare == "not done":
threshold = "Not used"
is_diff = "Not used"
label = "%s / %s" % (studyLabel, caseLabel)
label = label.replace("_", "\_")
self.tabWrite([label, is_compil, is_run, is_time, is_diff])
def close(self):
self.tabClose()
self.appendLine("\\section{Log}")
self.appendLine("\\tiny\n\\begin{verbatim}")
f = open(self.report)
self.rawLine(f.read())
f.close()
self.appendLine("\\end{verbatim}\n\\normalsize")
self.appendLine("\\section{File of commands}")
self.appendLine("\\tiny\n\\begin{verbatim}")
self.rawLine(self.xml)
self.appendLine("")
self.appendLine("\\end{verbatim}\n\\normalsize")
self.write()
return self.make_pdf()
#-------------------------------------------------------------------------------
class Report2(TexWriter):
"""
Detailled report.
"""
def __init__(self, dest, label, log):
"""
"""
TexWriter.__init__(self, dest, label, log)
def add_row(self, values, studyLabel, caseLabel):
nbvalue = len(values)
row_max = 40
if nbvalue:
self.tabCreate(["Variable Name", "Diff. Max", "Diff. Mean", "Threshold"])
for j in range(len(values)):
self.tabWrite([values[j][0], values[j][1], values[j][2], values[j][3]])
self.tabClose()
self.appendLine("\n \\newpage \n")
def close(self):
self.write()
return self.make_pdf()
#-------------------------------------------------------------------------------
def test():
"""
Test function.
The pupose is to build 2 documents:
1. a global report for all cases:
2. a detailled report for each case:
"""
dest = os.getcwd()
doc = Report1(dest, "r1")
compil = True
run = True
compare = True
diff = True
repo = True
threshold = 1.e-15
doc.add_row("MYSTUDY", "MYCASE", compil, run, compare, diff, repo, threshold)
doc.close()
msg = """
.----------------------------.
| Code_Saturne file dump |
`----------------------------'
Opening input file: "RESU/20110217-2231/checkpoint/main"
File type: Checkpoint / restart, R0
Base header size: 128
Header alignment: 64
Body alignment: 64
Opening input file: "RESU/20110217-2233/checkpoint/main"
File type: Checkpoint / restart, R0
Base header size: 128
Header alignment: 64
Body alignment: 64
"nbre_pas_de_temps "; Location: 0; Type: i4 ; Size: 1
Differences: 1
"instant_precedent "; Location: 0; Type: r8 ; Size: 1
Differences: 1; Max: 200; Mean: 200
"pression_ce_phase01 "; Location: 1; Type: r8 ; Size: 14574
Differences: 14574; Max: 3.09509; Mean: 0.159934
"vitesse_u_ce_phase01 "; Location: 1; Type: r8 ; Size: 14574
Differences: 14574; Max: 2.00929; Mean: 0.118064
"vitesse_v_ce_phase01 "; Location: 1; Type: r8 ; Size: 14574
Differences: 14574; Max: 1.84415; Mean: 0.065676
"vitesse_w_ce_phase01 "; Location: 1; Type: r8 ; Size: 14574
Differences: 14574; Max: 1.15005; Mean: 0.093984
"k_ce_phase01 "; Location: 1; Type: r8 ; Size: 14574
Differences: 14574; Max: 2.49588; Mean: 0.0191537
"eps_ce_phase01 "; Location: 1; Type: r8 ; Size: 14574
Differences: 14574; Max: 7438.13; Mean: 12.6477
"scalaire_ce_0001 "; Location: 1; Type: r8 ; Size: 14574
Differences: 14500; Max: 0.11862; Mean: 0.00345369
"""
doc = Report2(dest, "r2")
v = []
info = msg.replace("\"", " ").replace(";", " ").replace(":", " ").split()
print(info)
repo = "RESU/20110217-2231/checkpoint/main"
dest = "RESU/20110217-2233/checkpoint/main"
for i in range(len(info)):
if info[i][:4] == 'Diff':
if info[i-3] not in ['i4', 'u4']:
v.append([info[i-7].replace("_", "\_"), info[i+3], info[i+5]])
print(v)
doc.add_row(v, "MYSTUDY", "MYCASE", threshold)
doc.close()
if __name__ == '__main__':
test()
#-------------------------------------------------------------------------------
|