Mercurial > roundup-cc
annotate examples/collect_demo3.py @ 20:3bb3d9a9f1b7
Filter by keywords and states.
Configuration via configuration file.
"No prio" grapf is displayed.
(./display_issues_demo.py is not yet dynamic, it needs all states)
author | Magnus Schieder <mschieder@intevation.de> |
---|---|
date | Mon, 22 Oct 2018 16:49:58 +0200 |
parents | |
children | 7a523e13fcb3 |
rev | line source |
---|---|
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
2 """Connect to roundup-tracker and save status to db for example demo1. |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
3 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
4 Run periodically as often as you want data points to be saved. |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
5 demo1 only tracks issues with a priority. |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
6 """ |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
7 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
8 import json |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
9 import configparser |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
10 from collect_issues import save_stats_in_db |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
11 import roundup_content_data as rcd |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
12 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
13 COLUMNS = "critical, urgent, bug, feature, wish" |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
14 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
15 config = configparser.ConfigParser() |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
16 config.read('config3.ini') |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
17 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
18 base_url = config.get("URL", "BaseURL") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
19 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
20 user = config.get("LOGIN","Username") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
21 password = config.get("LOGIN", "Password") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
22 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
23 LOGIN_PARAMETERS_DEMO = ( |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
24 ("__login_name", user), |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
25 ("__login_password", password), |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
26 ("@action", "Login"), |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
27 ) |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
28 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
29 database_file = config.get("DB", "DatabaseFile") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
30 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
31 keywords = config.get("SEARCH", "Keywords", fallback="").split(", ") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
32 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
33 list_of_columns = config.get("SEARCH", "Columns", fallback=COLUMNS).split(", ") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
34 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
35 status = config.get("SEARCH", "Status", fallback="").split(", ") |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
36 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
37 include_no_prio = config.getboolean("SEARCH", "IncludeNoPrio", fallback= False) |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
38 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
39 if include_no_prio: |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
40 list_of_columns += ["None"] |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
41 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
42 select_all, select_where, create_db, insert_new = \ |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
43 rcd.build_sql_commands(list_of_columns) |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
44 |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
45 save_stats_in_db(LOGIN_PARAMETERS_DEMO, base_url, database_file, |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
diff
changeset
|
46 list_of_columns, create_db, insert_new, keywords, status) |