comparison display_issues.py @ 14:b5f7a439bddd

Allow to override default graph.html file
author Gernot Schulz <gernot@intevation.de>
date Sun, 31 Jan 2016 15:41:35 +0100
parents 149d01f43e31
children adca5b3780d2
comparison
equal deleted inserted replaced
13:149d01f43e31 14:b5f7a439bddd
38 for item in array: 38 for item in array:
39 formated.append("{date : new Date('" + str(item) + "')}") 39 formated.append("{date : new Date('" + str(item) + "')}")
40 40
41 return ", ".join(formated) 41 return ", ".join(formated)
42 42
43 def get_webpage(): 43 def get_webpage(graph=None):
44 44
45 graph = os.path.dirname(os.path.realpath(__file__)) + '/graph.html' 45 if graph is None:
46 graph = os.path.dirname(os.path.realpath(__file__)) + '/graph.html'
46 47
47 with open(graph, "r") as html_chart_file: 48 with open(graph, "r") as html_chart_file:
48 base_html_data = html_chart_file.read() 49 base_html_data = html_chart_file.read()
49 50
50 base_html_data = (base_html_data 51 base_html_data = (base_html_data
55 .replace("var wish=[];", "var wish=[" + make_js_object_string(rcd.data_dict["wish"]) + "]") 56 .replace("var wish=[];", "var wish=[" + make_js_object_string(rcd.data_dict["wish"]) + "]")
56 .replace("var timestamp=[];", "var timestamp=[" + make_js_object_date(rcd.data_dict["date"]) + "]")) 57 .replace("var timestamp=[];", "var timestamp=[" + make_js_object_date(rcd.data_dict["date"]) + "]"))
57 58
58 return base_html_data 59 return base_html_data
59 60
60 def compile_db_stats_html(db_file, sql_select): 61 def compile_db_stats_html(db_file, sql_select, graph=None):
61 62
62 con = None 63 con = None
63 cur = None 64 cur = None
64 65
65 try: 66 try:
78 if cur: 79 if cur:
79 cur.close() 80 cur.close()
80 if con: 81 if con:
81 con.close() 82 con.close()
82 83
83 return get_webpage() 84 return get_webpage(graph)
84 85
85 def render_webpage(content): 86 def render_webpage(content):
86 for line in content.split("\n"): 87 for line in content.split("\n"):
87 print(line) 88 print(line)
88 89
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)