bernhard@3: #!/usr/bin/env python3 bernhard@3: bernhard@3: """ Fetch issues from a roundup-tracker and save them in a databse. bernhard@3: bernhard@3: author: Sascha L. Teichmann bernhard@3: author: Bernhard Reiter bernhard@3: author: Sean Engelhardt bernhard@3: bernhard@17: (c) 2010, 2015, 2018 by Intevation GmbH bernhard@3: bernhard@3: This is Free Software unter the terms of the bernhard@3: GNU GENERAL PUBLIC LICENSE Version 3 or later. bernhard@3: See http://www.gnu.org/licenses/gpl-3.0.txt for details bernhard@3: """ mschieder@20: import configparser mschieder@21: import argparse mschieder@20: from display_issues import * bernhard@3: mschieder@26: def main(): mschieder@26: PRIO = "critical, urgent, bug, feature, wish" mschieder@26: STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved" mschieder@21: mschieder@26: parser = argparse.ArgumentParser() mschieder@26: parser.add_argument("config_file", type=str, metavar="[config file]") mschieder@26: args = parser.parse_args() mschieder@20: mschieder@26: config = configparser.ConfigParser() mschieder@26: config.read(args.config_file) mschieder@25: mschieder@26: db = config.get("DB", "DatabaseFile") mschieder@26: keywords = config.get("SEARCH", "Keywords", fallback="") mschieder@25: mschieder@25: mschieder@26: search = config.get("SEARCH", "Search", fallback="prio") mschieder@26: if search == "prio": mschieder@26: status = config.get("SEARCH", "Status", fallback="") mschieder@26: columns = config.get("SEARCH", "Priority", fallback=PRIO) mschieder@26: noPrio = config.get("SEARCH", "IncludeNoPrio", fallback=False) mschieder@26: if noPrio: mschieder@26: columns += ", None" mschieder@26: mschieder@26: elif search == "status": mschieder@26: columns = config.get("SEARCH", "Status", fallback=STATES) mschieder@26: status = "" mschieder@26: mschieder@25: else: mschieder@26: print("Incorrect [SEARCH]Search parameter. (prio, status)") mschieder@26: return mschieder@25: mschieder@28: # roundup uses a "-" in its search parameters. Sql can't handle it. mschieder@28: columns = columns.replace("-", "_") bernhard@3: mschieder@26: cgitb.enable() # (optional) HTML traceback to browser mschieder@26: #render_db_stats_as_html("./demo1.db", rcd.SELECT_ALL) mschieder@26: render_db_stats_as_html(db, mschieder@26: rcd.build_sql_select(columns).format("timestamp > date('now', '-2 month')"), mschieder@26: columns, status, keywords) mschieder@26: mschieder@26: if __name__ == '__main__': mschieder@26: main()