Functions | Variables
CronlogPageMakers Namespace Reference

Functions

def makeIndexPage (options, name, status, gantt=False)
 Make the index page. More...
 
def makeCronlogPages (options)
 Make all the individual pages. More...
 
def makeCronlogPage (options, cronlog)
 Make all the individual page. More...
 
def makeCrontabPage (options)
 Make all the individual page. More...
 

Variables

string cronlog_directory = "%s/"
 

Function Documentation

def CronlogPageMakers.makeCronlogPage (   options,
  cronlog 
)

Make all the individual page.

Definition at line 119 of file CronlogPageMakers.py.

References open().

Referenced by makeCronlogPages().

119 def makeCronlogPage(options, cronlog):
120  if options.verbose: print "PMS : Making cronlog page for log: %s"%cronlog
121  ########################### Imports
122  import PageMaker as PM
123  import ProductionTestTools as tools
124  ########################### Base HTML
125  name = cronlog.split("/")[-1].replace("txt","html")
126  pretty_name = name.replace("_"," ").replace(".html","")
127  base_html = \
128  """
129  <!-- Masthead ================================================== -->
130  <header class="mastheader row" id="header">
131  <div class="span12">
132  <div class="page-header">
133  <h1>%s</h1>
134  </div>
135  </div>
136  </header>
137 
138  <section>
139  <pre>CONTENT</pre>
140  </section>
141  """%pretty_name
142  ########################### Insert content
143  page = PM.PageMaker("cronlogs/"+name, base_html, options.verbose )
144  content = open(cronlog,"r").read()
145  content = content.replace("<","&lt;")
146  content = content.replace(">","&gt;")
147  page.insertContent("CONTENT",content,destructive=True)
148  ########################### Analyse content
149  lines = content.split("\n")
150  start_date = None
151  end_date = None
152  done = False
153  error = False
154  for i,line in enumerate(lines):
155  if ("--- Start date:" in line) and (len(lines) > (i+1)):
156  start_date = tools.cronlogLineToDate(lines[i+1])
157  if ("--- End date:" in line) and (len(lines) > (i+1)):
158  end_date = tools.cronlogLineToDate(lines[i+1])
159  if ("--- Lock file" in line):
160  error = line+", "+lines[i+1]
161  if ("--- done" in line):
162  done = True
163  if ("Error" in line.split(":")[0]):
164  print line
165  error = line
166  if ("JOBSUB" in line) and ("Failed" in line):
167  print line
168  error = line
169  delta_time = None
170  if (start_date != None) and (end_date != None):
171  delta_time = end_date - start_date
172  ########################### Write
173  page.write()
174  ########################### Return status
175  return done, error, delta_time, start_date, end_date
176 
def makeCronlogPage(options, cronlog)
Make all the individual page.
procfile open("FD_BRL_v0.txt")
def CronlogPageMakers.makeCronlogPages (   options)

Make all the individual pages.

Definition at line 100 of file CronlogPageMakers.py.

References makeCronlogPage().

100 def makeCronlogPages(options):
101  if options.verbose: print "PMS : Making cronlog pages"
102  ########################### Imports
103  import glob
104  ########################### Make
105  file_list = glob.glob(cronlog_directory+"cronlog_*")
106 
107  statuses = {}
108  for cronlog in file_list:
109  if "cronlog_make_cronlog_page.txt" in cronlog: continue
110  try:
111  statuses[cronlog] = makeCronlogPage(options,cronlog)
112  except IOError:
113  print cronlog, "cannot be opened"
114  continue
115  return statuses
116 
def makeCronlogPages(options)
Make all the individual pages.
def makeCronlogPage(options, cronlog)
Make all the individual page.
def CronlogPageMakers.makeCrontabPage (   options)

Make all the individual page.

Definition at line 179 of file CronlogPageMakers.py.

References open().

179 def makeCrontabPage(options):
180  if options.verbose: print "PMS : Making crontab"
181  ########################### Imports
182  import PageMaker as PM
183  import ProductionTestTools as tools
184  import os
185  ########################### Get the crontab
186  crontab = cronlog_directory+"crontab"
187  os.system("crontab -l >& %s"%crontab)
188  ########################### Base HTML
189  base_html = \
190  """
191  <!-- Masthead ================================================== -->
192  <header class="mastheader row" id="header">
193  <div class="span12">
194  <div class="page-header">
195  <h1>Crontab</h1>
196  </div>
197  </div>
198  </header>
199 
200  <section>
201  <pre>CONTENT</pre>
202  </section>
203  """
204  ########################### Insert content
205  page = PM.PageMaker("cronlogs/crontab.html", base_html, options.verbose)
206  content = open(crontab,"r").read()
207  content = content.replace("<","&lt;")
208  content = content.replace(">","&gt;")
209  page.insertContent("CONTENT",content,destructive=True)
210  ########################### Status
211  gantt = tools.crontabToGantt(content, to_skip=["make_cronlog_page","cronlog_test", "crontab","heartbeat"], verbose=options.verbose)
212  ########################### Write
213  page.write()
214  ########################### Return gantt
215  return gantt
216 
def makeCrontabPage(options)
Make all the individual page.
procfile open("FD_BRL_v0.txt")
def CronlogPageMakers.makeIndexPage (   options,
  name,
  status,
  gantt = False 
)

Make the index page.

Definition at line 5 of file CronlogPageMakers.py.

References open().

5 def makeIndexPage(options, name, status, gantt=False):
6  if options.verbose: print "PMS : Making dataset page for: %s"%name
7  ########################### Imports
8  import PageMaker as PM
9  import ViewHTML as html_view
10  import glob
11  import json
12  import ProductionTestTools as tools
13  ########################### Base HTML
14  base_html = \
15  """
16  <div class="page-header">
17  <h1>Cronlogs</h1>
18  </div>
19 
20  <div class="alert alert-info bs-alert-old-docs" role="alert">
21  <p>
22  This page displays all the cronlogs found in the directory:
23  <strong>%s</strong>
24  </p>
25  </div>
26 
27  <div class="panel panel-default">
28  <!--TABLE_HOOK-->
29  </div>
30  <hr>
31  <div class="panel panel-default">
32  <!--CRONTAB_TABLE_HOOK-->
33  </div>
34  <hr>
35  <div id="gantt"></div>
36  """%cronlog_directory
37  ########################### Insert content
38  page = PM.PageMaker(name, base_html, options.verbose)
39  ########################### CSS for the plot
40  css = \
41  """
42  .axis path,
43  .axis line {
44  fill: none;
45  stroke: #000;
46  shape-rendering: crispEdges;
47  }
48  .running {
49  fill: #337ab7;
50  }
51 
52  .running:hover {
53  fill: brown;
54  }
55 
56  .good {
57  fill: #5cb85c;
58  }
59 
60  .bad {
61  fill: #d9534f;
62  }
63 
64  .pending {
65  fill: grey;
66  opacity: 0.5;
67  }
68  .tooltip-inner {
69  max-width: 500px !important;
70  }
71  """
72  page.insertContent("/*STYLE_HOOK*/",css)
73 
74  summary_table = html_view.directoryToTable(cronlog_directory+"cronlog_*", "http://nusoft.fnal.gov/nova/production/cronlogs/", status=status, to_skip=["cronlog_make_cronlog_page.txt"], verbose=options.verbose)
75  page.insertContent("<!--TABLE_HOOK-->",summary_table)
76 
77  crontab_table = html_view.directoryToTable(cronlog_directory+"crontab", "http://nusoft.fnal.gov/nova/production/cronlogs/")
78  page.insertContent("<!--CRONTAB_TABLE_HOOK-->",crontab_table)
79 
80  # page.insertContent("<!--JS_HOOK-->",open("d3_crontab_gantt.html").read())
81  scripts = \
82  """
83  <script src="http://nusoft.fnal.gov/nova/production/static/d3.v3.min.js"></script>
84  """
85  scripts += open("%s/web/templates/template_cronlog_gantt_chart_script.html"%os.environ["NOVAPRODVALID_DIR"],"r").read()
86  page.insertContent("<!--JS_HOOK-->",scripts)
87 
88  gantt = tools.directoryToGantt(cronlog_directory+"cronlog_*", status, to_skip=["cronlog_make_cronlog_page.txt","cronlog_test.txt","cronlog_lemmon_heartbeat.txt"], verbose=options.verbose, gantt=gantt)
89  # print gantt
90  # assert False
91  page.insertContent("STARTTIMES",json.dumps(gantt["start"]), destructive=True)
92  page.insertContent("ENDTIMES", json.dumps(gantt["end"]), destructive=True)
93  page.insertContent("NAMES", json.dumps(gantt["name"]), destructive=True)
94  page.insertContent("CLASSES", json.dumps(gantt["class"]), destructive=True)
95  ########################### Write
96  page.write()
97 
def makeIndexPage(options, name, status, gantt=False)
Make the index page.
procfile open("FD_BRL_v0.txt")

Variable Documentation

string CronlogPageMakers.cronlog_directory = "%s/"

Definition at line 2 of file CronlogPageMakers.py.