Mercurial > roundup-cc
annotate collect_issues.py @ 31:9aca070c86bd
Add the filter 'priority' for the search by status.
author | Magnus Schieder <mschieder@intevation.de> |
---|---|
date | Thu, 22 Nov 2018 19:34:53 +0100 |
parents | 0d6504d02a6b |
children | 80bbd06fe8ec |
rev | line source |
---|---|
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
2 """ Fetch issues from a roundup-tracker and save them in a databse. |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
3 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
4 author: Sascha L. Teichmann <sascha.teichmann@intevation.de> |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
5 author: Bernhard Reiter <bernhard@intevation.de> |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
6 author: Sean Engelhardt <sean.engelhardt@intevation.de> |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
7 |
15
d0c439d1e833
Prepare for tracker entries without priority.
Bernhard Reiter <bernhard@intevation.de>
parents:
9
diff
changeset
|
8 (c) 2010, 2015, 2018 by Intevation GmbH |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
9 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
10 This is Free Software unter the terms of the |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
11 GNU GENERAL PUBLIC LICENSE Version 3 or later. |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
12 See http://www.gnu.org/licenses/gpl-3.0.txt for details |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
13 |
17
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
15
diff
changeset
|
14 For usage see examples/. |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
15 """ |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
16 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
17 import http.cookiejar |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
18 import urllib.parse |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
19 import urllib.request |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
20 import csv |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
21 import io |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
22 import sqlite3 as db |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
23 import os |
27
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
24 import sys |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
25 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
26 |
25
7161ce4e7ab1
The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
27 # Getting keywords and their ids. |
27
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
28 CHECK_KEYWORD_VALUES = "keyword?@action=export_csv&@columns=id,name" |
25
7161ce4e7ab1
The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
29 # Getting states and their ids. |
27
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
30 CHECK_STATUS_VALUES = "status?@action=export_csv&@columns=id,name" |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
31 # Getting priority and their ids. |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
32 CHECK_PRIO_VALUES = "priority?@action=export_csv&@columns=id,name" |
27
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
33 |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
34 # Getting the priority of each issue with the filter status ,keywords ,priority |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
35 SEARCH_ROUNDUP_PRIO = "issue?@action=export_csv&@columns=priority&@filter=status,keyword,priority&@pagesize=500&@startwith=0&status={status_values}&keyword={keyword_values}&priority={priority_values}" |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
36 # Getting the status of each issue with the filter keywords, status |
31
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
37 SEARCH_ROUNDUP_STATUS = "issue?@action=export_csv&@columns=status&@filter=priority,keyword,status&@pagesize=500&@startwith=0&priority={priority_values}&keyword={keyword_values}&status={status_values}" |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
38 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
39 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
40 def connect_to_server(params, baseurl): |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
41 enc_data = urllib.parse.urlencode(params).encode() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
42 cj = http.cookiejar.CookieJar() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
43 opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
44 req = urllib.request.Request(url=baseurl, data=enc_data) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
45 opener.open(req) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
46 return opener |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
47 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
48 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
49 def get_csv_from_server(opener, roundup_url, sub_url): |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
50 csv_req = urllib.request.Request(url=roundup_url+sub_url) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
51 f = opener.open(csv_req) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
52 csv_reader = csv.DictReader(io.TextIOWrapper(f)) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
53 return csv_reader |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
54 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
55 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
56 def check_create_database(database_file, sql_create_db): |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
57 if not os.path.isfile(database_file): |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
58 con = None |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
59 cur = None |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
60 try: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
61 con = db.connect(database_file) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
62 cur = con.cursor() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
63 try: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
64 cur.execute(sql_create_db) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
65 con.commit() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
66 os.chmod(database_file, 0o644) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
67 except: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
68 con.rollback() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
69 raise |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
70 finally: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
71 if cur: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
72 cur.close() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
73 if con: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
74 con.close() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
75 |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
76 def get_ids(opener, baseurl, parameter, url, include_no_prio=False): |
27
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
77 if parameter == [""]: |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
78 return ("", []) |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
79 |
27
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
80 parameter_csv = get_csv_from_server(opener, baseurl, url) |
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
81 parameter_dict = {} |
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
82 for x in parameter_csv: |
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
83 parameter_dict[x["name"]] = x["id"] |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
84 |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
85 if include_no_prio: |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
86 parameter_dict["None"] = "-1" |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
87 |
27
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
88 parameter_ids = [] |
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
89 for x in parameter: |
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
90 if x not in parameter_dict: |
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
91 print('The parameter "%s" does not exist in the tracker.' % x) |
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
92 sys.exit(0) |
25
7161ce4e7ab1
The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
93 |
27
cdab667c6abb
Delete Code Duplication and Clean Up.
Magnus Schieder <mschieder@intevation.de>
parents:
26
diff
changeset
|
94 parameter_ids.append(parameter_dict[x]) |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
95 |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
96 return (",".join(parameter_ids), parameter_ids) |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
97 |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
98 |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
99 def issues_to_quantities(issue_csv, columns_ids): |
15
d0c439d1e833
Prepare for tracker entries without priority.
Bernhard Reiter <bernhard@intevation.de>
parents:
9
diff
changeset
|
100 """Count issues per priority. |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
101 |
15
d0c439d1e833
Prepare for tracker entries without priority.
Bernhard Reiter <bernhard@intevation.de>
parents:
9
diff
changeset
|
102 Returns: a list of ints, containing how often a prio occurred [:-1] |
d0c439d1e833
Prepare for tracker entries without priority.
Bernhard Reiter <bernhard@intevation.de>
parents:
9
diff
changeset
|
103 in order of the priorities, with the last being the "None" prio |
d0c439d1e833
Prepare for tracker entries without priority.
Bernhard Reiter <bernhard@intevation.de>
parents:
9
diff
changeset
|
104 """ |
d0c439d1e833
Prepare for tracker entries without priority.
Bernhard Reiter <bernhard@intevation.de>
parents:
9
diff
changeset
|
105 |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
106 order_dict = {} |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
107 z = 0 |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
108 for x in columns_ids: |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
109 order_dict[x] = z |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
110 z += 1 |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
111 |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
112 quantities = [0] * z |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
113 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
114 for issue in issue_csv: |
25
7161ce4e7ab1
The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
115 priority = issue[issue_csv.fieldnames[0]] |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
116 |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
117 if priority in order_dict: |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
118 if priority.isdigit() == True : |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
119 quantities[order_dict[priority]] += 1 |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
120 else: |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
121 quantities[-1] += 1 |
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
122 #print("quantities : " + str(quantities)) |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
123 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
124 return quantities |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
125 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
126 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
127 def save_issues_to_db(quantities, database_file, sql_create_db, sql_insert_in_db): |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
128 check_create_database(database_file, sql_create_db) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
129 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
130 cur = None |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
131 con = None |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
132 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
133 try: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
134 con = db.connect(database_file) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
135 cur = con.cursor() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
136 try: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
137 cur.execute(sql_insert_in_db, quantities) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
138 con.commit() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
139 except: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
140 con.rollback() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
141 raise |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
142 finally: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
143 if cur: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
144 cur.close() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
145 if con: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
146 con.close() |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
147 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
148 |
31
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
149 def save_stats_in_db(search, login_parmeters, baseurl, db_file, columns, sql_create_db, sql_insert_in_db, keywords, search_parameters, include_no_prio): |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
150 try: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
151 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
152 opener = connect_to_server(login_parmeters, baseurl) |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
153 |
31
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
154 keywords_ids_url, _ = get_ids(opener, baseurl, keywords, |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
155 CHECK_KEYWORD_VALUES) |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
156 |
25
7161ce4e7ab1
The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
157 if search == "prio": |
31
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
158 # search_parameters are statuses. |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
159 status_ids_url, _ = get_ids(opener, baseurl,search_parameters , |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
160 CHECK_STATUS_VALUES, include_no_prio) |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
161 prio_ids_url, columns_ids = get_ids(opener, baseurl, columns, |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
162 CHECK_PRIO_VALUES, include_no_prio) |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
163 formated_search_url = SEARCH_ROUNDUP_PRIO.format( |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
164 status_values=status_ids_url, |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
165 keyword_values=keywords_ids_url, |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
166 priority_values=prio_ids_url) |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
167 |
25
7161ce4e7ab1
The web-based display is dynamically generated.
Magnus Schieder <mschieder@intevation.de>
parents:
20
diff
changeset
|
168 elif search == "status": |
31
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
169 # search_parameters are priorities. |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
170 prio_ids_url, _ = get_ids(opener, baseurl, search_parameters, |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
171 CHECK_PRIO_VALUES, include_no_prio) |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
172 status_ids_url, columns_ids = get_ids(opener, baseurl, columns, |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
173 CHECK_STATUS_VALUES) |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
174 formated_search_url = SEARCH_ROUNDUP_STATUS.format( |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
175 priority_values=prio_ids_url, |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
176 keyword_values=keywords_ids_url, |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
177 status_values=status_ids_url) |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
178 |
31
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
179 current_issues_csv = get_csv_from_server(opener, baseurl, |
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
180 formated_search_url) |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
181 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
182 opener.close() |
31
9aca070c86bd
Add the filter 'priority' for the search by status.
Magnus Schieder <mschieder@intevation.de>
parents:
30
diff
changeset
|
183 print(baseurl + formated_search_url) |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
184 |
28
e2864dabdb8c
fixes a logical error in the filtering of columns.
Magnus Schieder <mschieder@intevation.de>
parents:
27
diff
changeset
|
185 quantities = issues_to_quantities(current_issues_csv, columns_ids) |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
186 |
9 | 187 save_issues_to_db(quantities, db_file, sql_create_db, sql_insert_in_db) |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
188 |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
189 except urllib.error.URLError as e: |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
diff
changeset
|
190 print("No Valid Connection to server : " + baseurl + "\nerror: " + str(e)) |