annotate roundup_cc.py @ 25:7161ce4e7ab1

The web-based display is dynamically generated. * All graphs are passed in one object. All graphs are passed in one object. The graphs are generated iteratiev and assigned a color. * roundup_cc.py can count how many issues are in which state.
author Magnus Schieder <mschieder@intevation.de>
date Mon, 12 Nov 2018 18:03:26 +0100
parents
children 761ee2351f58
rev   line source
25
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
1 #!/usr/bin/env python3
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
2 """Connect to roundup-tracker and save status to db.
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
3
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
4 Run periodically as often as you want data points to be saved.
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
5 """
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
6
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
7 import configparser
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
8 import argparse
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
9
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
10 from collect_issues import save_stats_in_db
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
11 import roundup_content_data as rcd
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
12
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
13 PRIO = "critical, urgent, bug, feature, wish"
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
14 STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved"
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
15
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
16 def main():
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
17
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
18 parser = argparse.ArgumentParser()
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
19 parser.add_argument("config_file", type=str, metavar="[config file]")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
20 args = parser.parse_args()
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
21
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
22 config = configparser.ConfigParser()
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
23 config.read(args.config_file)
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
24
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
25 base_url = config.get("URL", "BaseURL")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
26
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
27 user = config.get("LOGIN","Username")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
28 password = config.get("LOGIN", "Password")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
29
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
30 login_parameters = (
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
31 ("__login_name", user),
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
32 ("__login_password", password),
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
33 ("@action", "Login"),
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
34 )
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
35
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
36 database_file = config.get("DB", "DatabaseFile")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
37
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
38 keywords = config.get("SEARCH", "Keywords", fallback="").split(", ")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
39
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
40 search = config.get("SEARCH", "Search", fallback="prio")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
41 if search == "prio":
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
42 list_of_columns = config.get("SEARCH", "Columns", fallback=PRIO).split(", ")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
43 status = config.get("SEARCH", "Status", fallback="").split(", ")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
44 include_no_prio = config.getboolean("SEARCH", "IncludeNoPrio", fallback= False)
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
45 if include_no_prio:
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
46 list_of_columns += ["None"]
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
47
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
48 elif search == "status":
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
49 list_of_columns = config.get("SEARCH", "Status", fallback=STATES).split(", ")
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
50 status = [""]
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
51
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
52 select_all, select_where, create_db, insert_new = \
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
53 rcd.build_sql_commands(list_of_columns)
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
54
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
55 save_stats_in_db(search, login_parameters, base_url, database_file,
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
56 list_of_columns, create_db, insert_new, keywords, status)
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
57
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
58 if __name__ == '__main__':
7161ce4e7ab1 The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
diff changeset
59 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)