CMS 3D CMS Logo

Functions | Variables
web.dbfile2html Namespace Reference

Functions

def create_page (path, content)
 
def dbfile2html (db_name, work_path, threshold=1e-5)
 

Variables

 action
 
 args
 
 default
 
 dest
 
 env
 
 help
 
 loader
 
 opts
 
 parser
 
 usage
 

Function Documentation

◆ create_page()

def web.dbfile2html.create_page (   path,
  content 
)

Definition at line 28 of file dbfile2html.py.

28 def create_page(path, content):
29  path = join(*path)
30  if not exists(dirname(path)):
31  makedirs(dirname(path))
32  f = open(path + '.html', 'w')
33  f.write(content)
34  f.close()
35 

References BTVHLTOfflineSource_cfi.dirname, and join().

Referenced by web.dbfile2html.dbfile2html().

◆ dbfile2html()

def web.dbfile2html.dbfile2html (   db_name,
  work_path,
  threshold = 1e-5 
)
Generates static HTML from given release comparison database file.
Algorithm: iterates through database, renders Jinja2 templates and saves
them to static HTML files.

Definition at line 36 of file dbfile2html.py.

36 def dbfile2html(db_name, work_path, threshold=1e-5):
37  """
38  Generates static HTML from given release comparison database file.
39  Algorithm: iterates through database, renders Jinja2 templates and saves
40  them to static HTML files.
41  """
42  if not exists(db_name):
43  print("\nError: SQLite3 database file does not exsits. Exitting...\n")
44  exit()
45 
46  conn = sqlite3.connect(db_name)
47  c = conn.cursor()
48 
49 
50  path = join(work_path, 'static_html')
51  if not exists(path):
52  makedirs(path)
53 
54  global_context = {'db_name': None , 'threshold': threshold,
55  'file_id': None, 'args': [], 'kwargs': None}
56  global_context['static_html'] = True
57  global_context['base_path'] = work_path.strip('/')
58 
59 
60  context = global_context.copy()
61  db_list_temp = env.get_template('db_list.html')
62  context['db_list'] = db_list_with_releases(work_path)
63  f = open(join(path, 'index.html'), 'w')
64  f.write(db_list_temp.render(context))
65 
66 
67  c.execute('''SELECT id, title, statistical_test FROM ReleaseComparison;''')
68  releases = c.fetchall()
69  rel_summary_temp = env.get_template('release_summary.html')
70  dir_summary_temp = env.get_template('directory_summary.html')
71 
72 
73  for rel_id, release_title, st_test in releases:
74  context = global_context.copy()
75  context.update(get_release_summary_stats(c, release_title, st_test, threshold))
76  context['release_title'] = release_title
77  context['st_test'] = st_test
78  create_page([path, release_title, st_test], rel_summary_temp.render(context))
79 
80 
81  print('Generating %s (%s) comparison pages...' % (release_title, st_test))
82  c.execute('''SELECT id, directory_id FROM RootFileComparison WHERE release_comparison_id = ?;''', (rel_id,))
83  for file_id, file_top_dir_id in c.fetchall():
84  context['file_id'] = file_id
85  context.update(get_directory_summary_stats(c, [], file_id, threshold))
86  create_page([path, release_title, st_test, str(file_id)], dir_summary_temp.render(context))
87 
88  c.execute('''SELECT id FROM Directory WHERE parent_id=?''', (file_top_dir_id,))
89  children_dirs = c.fetchall()
90 
91 
92  def create_dir_pages(c, dir_id, dir_path):
93  # Generate Directory page
94  c.execute('''SELECT name FROM Directory WHERE id=?''', (dir_id,))
95  dir_path.append(c.fetchone()[0])
96  context.update(get_directory_summary_stats(c, dir_path, file_id, threshold))
97  create_page([path, release_title, st_test, str(file_id)] + dir_path, dir_summary_temp.render(context))
98  # TODO: Call for subdirectories
99 
100  for children_dir in children_dirs:
101  create_dir_pages(c, children_dir[0], [])
102  print('Done.')
103 
104 

References web.dbfile2html.create_page(), web.app_utils.db_list_with_releases(), beamvalidation.exit(), web.app_utils.get_directory_summary_stats(), web.app_utils.get_release_summary_stats(), join(), edm.print(), and str.

Variable Documentation

◆ action

web.dbfile2html.action

Definition at line 23 of file dbfile2html.py.

◆ args

web.dbfile2html.args

Definition at line 106 of file dbfile2html.py.

◆ default

web.dbfile2html.default

Definition at line 25 of file dbfile2html.py.

◆ dest

web.dbfile2html.dest

Definition at line 23 of file dbfile2html.py.

◆ env

web.dbfile2html.env

Definition at line 20 of file dbfile2html.py.

◆ help

web.dbfile2html.help

Definition at line 24 of file dbfile2html.py.

◆ loader

web.dbfile2html.loader

Definition at line 20 of file dbfile2html.py.

◆ opts

web.dbfile2html.opts

Definition at line 106 of file dbfile2html.py.

◆ parser

web.dbfile2html.parser

Definition at line 22 of file dbfile2html.py.

◆ usage

web.dbfile2html.usage

Definition at line 22 of file dbfile2html.py.

join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
BTVHLTOfflineSource_cfi.dirname
dirname
Definition: BTVHLTOfflineSource_cfi.py:7
web.app_utils.get_release_summary_stats
def get_release_summary_stats(c, release_title, st_test, threshold=1e-5)
Definition: app_utils.py:165
str
#define str(s)
Definition: TestProcessor.cc:48
web.app_utils.get_directory_summary_stats
def get_directory_summary_stats(c, url_args, file_id, threshold)
Definition: app_utils.py:285
web.app_utils.db_list_with_releases
def db_list_with_releases(path='.')
Definition: app_utils.py:152
web.dbfile2html.dbfile2html
def dbfile2html(db_name, work_path, threshold=1e-5)
Definition: dbfile2html.py:36
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
web.dbfile2html.create_page
def create_page(path, content)
Definition: dbfile2html.py:28