annotate roundup_cc_display.py @ 36:59e1659a0a0b tip

Update 'TODO.creole' * Old TODOs moved to 'doc/old_TODO.creole'
author Magnus Schieder <mschieder@intevation.de>
date Mon, 26 Nov 2018 16:52:45 +0100
parents 80bbd06fe8ec
children
rev   line source
3
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
1 #!/usr/bin/env python3
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
2
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
3 """ Fetch issues from a roundup-tracker and save them in a databse.
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
4
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
5 author: Sascha L. Teichmann <sascha.teichmann@intevation.de>
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
6 author: Bernhard Reiter <bernhard@intevation.de>
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
7 author: Sean Engelhardt <sean.engelhardt@intevation.de>
32
80bbd06fe8ec Add Comments
Magnus Schieder <mschieder@intevation.de>
parents: 31
diff changeset
8 author: Magnus Schieder <magnus.schieder@intevation.de>
3
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
9
17
adca5b3780d2 Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents: 13
diff changeset
10 (c) 2010, 2015, 2018 by Intevation GmbH
3
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
11
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
12 This is Free Software unter the terms of the
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
13 GNU GENERAL PUBLIC LICENSE Version 3 or later.
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
14 See http://www.gnu.org/licenses/gpl-3.0.txt for details
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
15 """
20
3bb3d9a9f1b7 Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents: 17
diff changeset
16 import configparser
21
7a523e13fcb3 Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents: 20
diff changeset
17 import argparse
20
3bb3d9a9f1b7 Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents: 17
diff changeset
18 from display_issues import *
3
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
19
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
20 def main():
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
21 PRIO = "critical, urgent, bug, feature, wish"
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
22 STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved"
21
7a523e13fcb3 Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents: 20
diff changeset
23
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
24 parser = argparse.ArgumentParser()
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
25 parser.add_argument("config_file", type=str, metavar="[config file]")
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
26 args = parser.parse_args()
20
3bb3d9a9f1b7 Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents: 17
diff changeset
27
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
28 config = configparser.ConfigParser()
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
29 config.read(args.config_file)
25
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents: 24
diff changeset
30
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
31 db = config.get("DB", "DatabaseFile")
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
32 keywords = config.get("SEARCH", "Keywords", fallback="")
25
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents: 24
diff changeset
33
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
34 search = config.get("SEARCH", "Search", fallback="prio")
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
35 if search == "prio":
31
9aca070c86bd Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents: 29
diff changeset
36 search_parameters = config.get("SEARCH", "Status", fallback="")
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
37 columns = config.get("SEARCH", "Priority", fallback=PRIO)
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
38 noPrio = config.get("SEARCH", "IncludeNoPrio", fallback=False)
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
39 if noPrio:
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
40 columns += ", None"
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
41
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
42 elif search == "status":
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
43 columns = config.get("SEARCH", "Status", fallback=STATES)
31
9aca070c86bd Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents: 29
diff changeset
44 search_parameters = config.get("SEARCH", "Priority", fallback="")
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
45
25
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents: 24
diff changeset
46 else:
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
47 print("Incorrect [SEARCH]Search parameter. (prio, status)")
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
48 return
25
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents: 24
diff changeset
49
28
e2864dabdb8c fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents: 26
diff changeset
50 # roundup uses a "-" in its search parameters. Sql can't handle it.
e2864dabdb8c fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents: 26
diff changeset
51 columns = columns.replace("-", "_")
3
99c68ebfb3b9 Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff changeset
52
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
53 cgitb.enable() # (optional) HTML traceback to browser
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
54 #render_db_stats_as_html("./demo1.db", rcd.SELECT_ALL)
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
55 render_db_stats_as_html(db,
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
56 rcd.build_sql_select(columns).format("timestamp > date('now', '-2 month')"),
31
9aca070c86bd Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents: 29
diff changeset
57 columns, search_parameters, keywords)
26
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
58
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
59 if __name__ == '__main__':
761ee2351f58 Change the parameter read in.
Magnus Schieder <mschieder@intevation.de>
parents: 25
diff changeset
60 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)