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

def web.dbfile2html.create_page (   path,
  content 
)

Definition at line 27 of file dbfile2html.py.

References compare_using_db.dirname, and join().

Referenced by web.dbfile2html.dbfile2html().

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

References web.dbfile2html.create_page(), web.app_utils.db_list_with_releases(), cmsRelvalreport.exit, web.app_utils.get_directory_summary_stats(), web.app_utils.get_release_summary_stats(), join(), and harvestTrackValidationPlots.str.

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

Variable Documentation

web.dbfile2html.action

Definition at line 22 of file dbfile2html.py.

web.dbfile2html.args

Definition at line 105 of file dbfile2html.py.

web.dbfile2html.default

Definition at line 24 of file dbfile2html.py.

web.dbfile2html.dest

Definition at line 22 of file dbfile2html.py.

web.dbfile2html.env

Definition at line 19 of file dbfile2html.py.

web.dbfile2html.help

Definition at line 23 of file dbfile2html.py.

web.dbfile2html.loader

Definition at line 19 of file dbfile2html.py.

web.dbfile2html.opts

Definition at line 105 of file dbfile2html.py.

web.dbfile2html.parser

Definition at line 21 of file dbfile2html.py.

web.dbfile2html.usage

Definition at line 21 of file dbfile2html.py.