Mercurial > roundup-cc
annotate display_issues_demo.py @ 21:7a523e13fcb3
Argpars added for the configuration file.
author | Magnus Schieder <mschieder@intevation.de> |
---|---|
date | Tue, 23 Oct 2018 13:06:16 +0200 |
parents | 3bb3d9a9f1b7 |
children | 89469aa41fe1 |
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> |
99c68ebfb3b9
Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff
changeset
|
8 |
17
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
13
diff
changeset
|
9 (c) 2010, 2015, 2018 by Intevation GmbH |
3
99c68ebfb3b9
Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff
changeset
|
10 |
99c68ebfb3b9
Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff
changeset
|
11 This is Free Software unter the terms of the |
99c68ebfb3b9
Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff
changeset
|
12 GNU GENERAL PUBLIC LICENSE Version 3 or later. |
99c68ebfb3b9
Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff
changeset
|
13 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
|
14 """ |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
15 import configparser |
21
7a523e13fcb3
Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
16 import argparse |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
17 from display_issues import * |
3
99c68ebfb3b9
Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff
changeset
|
18 |
21
7a523e13fcb3
Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
19 parser = argparse.ArgumentParser() |
7a523e13fcb3
Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
20 parser.add_argument("config_file", type=str, metavar="[config file]") |
7a523e13fcb3
Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
21 args = parser.parse_args() |
7a523e13fcb3
Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
22 |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
23 config = configparser.ConfigParser() |
21
7a523e13fcb3
Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
24 config.read(args.config_file) |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
25 |
21
7a523e13fcb3
Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
26 db = config.get("DB", "DatabaseFile") |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
27 keywords = config.get("SEARCH", "Keywords", fallback="") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
28 status = config.get("SEARCH", "Status", fallback="") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
29 columns = config.get("SEARCH", "Columns", fallback="critical, urgent, bug, feature, wish") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
30 noPrio = config.get("SEARCH", "IncludeNoPrio", fallback=False) |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
31 if noPrio: |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
32 columns += ", None" |
3
99c68ebfb3b9
Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff
changeset
|
33 |
99c68ebfb3b9
Streamlined to example use.
Bernhard Reiter <bernhard@intevation.de>
parents:
diff
changeset
|
34 cgitb.enable() # (optional) HTML traceback to browser |
17
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
13
diff
changeset
|
35 #render_db_stats_as_html("./demo1.db", rcd.SELECT_ALL) |
21
7a523e13fcb3
Argpars added for the configuration file.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
36 render_db_stats_as_html(db, |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
37 rcd.build_sql_select(columns).format("timestamp > date('now', '-2 month')"), |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
38 status, keywords) |