comparison display_issues_demo.py @ 26:761ee2351f58

Change the parameter read in. * The structure was changed and better names used.
author Magnus Schieder <mschieder@intevation.de>
date Tue, 13 Nov 2018 17:55:10 +0100
parents 7161ce4e7ab1
children e2864dabdb8c
comparison
equal deleted inserted replaced
25:7161ce4e7ab1 26:761ee2351f58
14 """ 14 """
15 import configparser 15 import configparser
16 import argparse 16 import argparse
17 from display_issues import * 17 from display_issues import *
18 18
19 STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved" 19 def main():
20 PRIO = "critical, urgent, bug, feature, wish"
21 STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved"
20 22
21 parser = argparse.ArgumentParser() 23 parser = argparse.ArgumentParser()
22 parser.add_argument("config_file", type=str, metavar="[config file]") 24 parser.add_argument("config_file", type=str, metavar="[config file]")
23 args = parser.parse_args() 25 args = parser.parse_args()
24 26
25 config = configparser.ConfigParser() 27 config = configparser.ConfigParser()
26 config.read(args.config_file) 28 config.read(args.config_file)
27 29
28 db = config.get("DB", "DatabaseFile") 30 db = config.get("DB", "DatabaseFile")
29 keywords = config.get("SEARCH", "Keywords", fallback="") 31 keywords = config.get("SEARCH", "Keywords", fallback="")
30 32
31 33
34 search = config.get("SEARCH", "Search", fallback="prio")
35 if search == "prio":
36 status = config.get("SEARCH", "Status", fallback="")
37 columns = config.get("SEARCH", "Priority", fallback=PRIO)
38 noPrio = config.get("SEARCH", "IncludeNoPrio", fallback=False)
39 if noPrio:
40 columns += ", None"
32 41
33 status = config.get("SEARCH", "Status", fallback="") 42 elif search == "status":
34 columns = config.get("SEARCH", "Columns", fallback="critical, urgent, bug, feature, wish") 43 columns = config.get("SEARCH", "Status", fallback=STATES)
35 noPrio = config.get("SEARCH", "IncludeNoPrio", fallback=False) 44 status = ""
36 search = config.get("SEARCH", "Search", fallback="prio") 45
37 if search == "status":
38 if status == "":
39 columns = STATES
40 else: 46 else:
41 columns = status 47 print("Incorrect [SEARCH]Search parameter. (prio, status)")
42 noPrio = False 48 return
43 49
44 if noPrio:
45 columns += ", None"
46 50
47 cgitb.enable() # (optional) HTML traceback to browser 51 cgitb.enable() # (optional) HTML traceback to browser
48 #render_db_stats_as_html("./demo1.db", rcd.SELECT_ALL) 52 #render_db_stats_as_html("./demo1.db", rcd.SELECT_ALL)
49 render_db_stats_as_html(db, 53 render_db_stats_as_html(db,
50 rcd.build_sql_select(columns).format("timestamp > date('now', '-2 month')"), 54 rcd.build_sql_select(columns).format("timestamp > date('now', '-2 month')"),
51 columns, status, keywords) 55 columns, status, keywords)
56
57 if __name__ == '__main__':
58 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)