CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
web.dbfile2html Namespace Reference

Functions

def create_page
 
def dbfile2html
 

Variables

tuple env = Environment(loader=FileSystemLoader('templates'))
 
string help = 'Absolute path to SQLite3 database file.'
 
tuple parser = OptionParser(usage='Usage: %prog --db PATH_TO_DB [options]')
 

Function Documentation

def web.dbfile2html.create_page (   path,
  content 
)

Definition at line 28 of file dbfile2html.py.

References HILowLumiHLTOfflineSource_cfi.dirname, and join().

Referenced by web.dbfile2html.dbfile2html().

28 
29 def create_page(path, content):
30  path = join(*path)
31  if not exists(dirname(path)):
32  makedirs(dirname(path))
33  f = open(path + '.html', 'w')
34  f.write(content)
35  f.close()
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
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.

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

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

Variable Documentation

tuple web.dbfile2html.env = Environment(loader=FileSystemLoader('templates'))

Definition at line 20 of file dbfile2html.py.

string web.dbfile2html.help = 'Absolute path to SQLite3 database file.'

Definition at line 24 of file dbfile2html.py.

tuple web.dbfile2html.parser = OptionParser(usage='Usage: %prog --db PATH_TO_DB [options]')

Definition at line 22 of file dbfile2html.py.