annotate roundup_content_data/__init__.py @ 13:149d01f43e31

Split up render_db_stats_as_html function Allow the generated HTML code to be either printed to stdout as before (render_db_stats_as_html) or be returned as a string (compile_db_stats_html). The latter is required for Bottledash.
author Gernot Schulz <gernot@intevation.de>
date Sun, 31 Jan 2016 13:15:08 +0100
parents 99e2e0e17103
children adca5b3780d2
rev   line source
0
3f139db894f1 initial commit
sean
parents:
diff changeset
1 #!/usr/bin/env python
3f139db894f1 initial commit
sean
parents:
diff changeset
2
3f139db894f1 initial commit
sean
parents:
diff changeset
3 """ supplys the data needed to comunicate with the roundup-server,
3f139db894f1 initial commit
sean
parents:
diff changeset
4 and the sqlite database. Represents the types of errors used in roundup.
3f139db894f1 initial commit
sean
parents:
diff changeset
5
3f139db894f1 initial commit
sean
parents:
diff changeset
6 author: Sascha L. Teichmann <sascha.teichmann@intevation.de>
3f139db894f1 initial commit
sean
parents:
diff changeset
7 author: Bernhard Reiter <bernhard@intevation.de>
3f139db894f1 initial commit
sean
parents:
diff changeset
8 author: Sean Engelhardt <sean.engelhardt@intevation.de>
3f139db894f1 initial commit
sean
parents:
diff changeset
9
3f139db894f1 initial commit
sean
parents:
diff changeset
10 (c) 2010,2015 by Intevation GmbH
3f139db894f1 initial commit
sean
parents:
diff changeset
11
3f139db894f1 initial commit
sean
parents:
diff changeset
12 This is Free Software unter the terms of the
3f139db894f1 initial commit
sean
parents:
diff changeset
13 GNU GENERAL PUBLIC LICENSE Version 3 or later.
3f139db894f1 initial commit
sean
parents:
diff changeset
14 See http://www.gnu.org/licenses/gpl-3.0.txt for details
3f139db894f1 initial commit
sean
parents:
diff changeset
15 """
3f139db894f1 initial commit
sean
parents:
diff changeset
16
3f139db894f1 initial commit
sean
parents:
diff changeset
17 import os
3f139db894f1 initial commit
sean
parents:
diff changeset
18
1
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
19 #Add desired sqlite databases here
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
20 DATABASE_REFERENCCE = os.path.dirname(os.path.realpath(__file__)) + "/test_reference.db"
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
21 DATABASE_DEMO = os.path.dirname(os.path.realpath(__file__)) + "/demo.db"
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
22 DATABASE_ERRORDB = os.path.dirname(os.path.realpath(__file__)) + "/errordatabase.db"
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
23 DATABASE_TECH_INTERN = os.path.dirname(os.path.realpath(__file__)) + "/tech_intern.db"
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
24 DATABASE_INT_TEST = os.path.dirname(os.path.realpath(__file__)) + "/int_test.db"
0
3f139db894f1 initial commit
sean
parents:
diff changeset
25
1
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
26 COLUMNS= [
0
3f139db894f1 initial commit
sean
parents:
diff changeset
27 "critical", "urgent", "bug", "feature", "wish",
3f139db894f1 initial commit
sean
parents:
diff changeset
28 ]
3f139db894f1 initial commit
sean
parents:
diff changeset
29
3f139db894f1 initial commit
sean
parents:
diff changeset
30 data_dict = {
3f139db894f1 initial commit
sean
parents:
diff changeset
31 "date": [],
3f139db894f1 initial commit
sean
parents:
diff changeset
32 "critical": [],
3f139db894f1 initial commit
sean
parents:
diff changeset
33 "urgent": [],
3f139db894f1 initial commit
sean
parents:
diff changeset
34 "bug": [],
3f139db894f1 initial commit
sean
parents:
diff changeset
35 "feature": [],
3f139db894f1 initial commit
sean
parents:
diff changeset
36 "wish": []
3f139db894f1 initial commit
sean
parents:
diff changeset
37 }
3f139db894f1 initial commit
sean
parents:
diff changeset
38
1
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
39 #SQL
0
3f139db894f1 initial commit
sean
parents:
diff changeset
40
1
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
41 #DEMO System
0
3f139db894f1 initial commit
sean
parents:
diff changeset
42 SELECT_ALL = """
3f139db894f1 initial commit
sean
parents:
diff changeset
43 SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp),
3f139db894f1 initial commit
sean
parents:
diff changeset
44 critical,
3f139db894f1 initial commit
sean
parents:
diff changeset
45 urgent,
3f139db894f1 initial commit
sean
parents:
diff changeset
46 bug,
3f139db894f1 initial commit
sean
parents:
diff changeset
47 feature,
3f139db894f1 initial commit
sean
parents:
diff changeset
48 wish
3f139db894f1 initial commit
sean
parents:
diff changeset
49 FROM issues
3f139db894f1 initial commit
sean
parents:
diff changeset
50 ORDER BY timestamp
3f139db894f1 initial commit
sean
parents:
diff changeset
51 """
3f139db894f1 initial commit
sean
parents:
diff changeset
52
7
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
53 SELECT_WHERE = """
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
54 SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp),
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
55 critical,
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
56 urgent,
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
57 bug,
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
58 feature,
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
59 wish
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
60 FROM issues
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
61 WHERE {}
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
62 ORDER BY timestamp
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
63 """
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
64
0
3f139db894f1 initial commit
sean
parents:
diff changeset
65
3f139db894f1 initial commit
sean
parents:
diff changeset
66 CREATE_DB = """
3f139db894f1 initial commit
sean
parents:
diff changeset
67 CREATE TABLE issues (
3f139db894f1 initial commit
sean
parents:
diff changeset
68 timestamp TIMESTAMP NOT NULL UNIQUE DEFAULT current_timestamp,
3f139db894f1 initial commit
sean
parents:
diff changeset
69 critical INTEGER NOT NULL DEFAULT 0,
3f139db894f1 initial commit
sean
parents:
diff changeset
70 urgent INTEGER NOT NULL DEFAULT 0,
3f139db894f1 initial commit
sean
parents:
diff changeset
71 bug INTEGER NOT NULL DEFAULT 0,
3f139db894f1 initial commit
sean
parents:
diff changeset
72 feature INTEGER NOT NULL DEFAULT 0,
3f139db894f1 initial commit
sean
parents:
diff changeset
73 wish INTEGER NOT NULL DEFAULT 0
3f139db894f1 initial commit
sean
parents:
diff changeset
74 )
3f139db894f1 initial commit
sean
parents:
diff changeset
75 """
3f139db894f1 initial commit
sean
parents:
diff changeset
76
3f139db894f1 initial commit
sean
parents:
diff changeset
77
3f139db894f1 initial commit
sean
parents:
diff changeset
78 INSERT_NEW = """
3f139db894f1 initial commit
sean
parents:
diff changeset
79 INSERT INTO issues (critical, urgent, bug, feature, wish)
3f139db894f1 initial commit
sean
parents:
diff changeset
80 VALUES (?, ?, ?, ?, ?)
1
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
81 """
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
82
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
83 #Referecen DB:
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
84 SELECT_ALL_REFERENCE = """
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
85 SELECT strftime("%Y-%m-%dT%H:%M:%S", sample_time),
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
86 critical,
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
87 major,
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
88 crash,
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
89 normal,
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
90 minor,
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
91 wishlist
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
92 FROM issues
2df45f6ecd81 new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents: 0
diff changeset
93 ORDER BY sample_time
7
99e2e0e17103 Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents: 1
diff changeset
94 """
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)