view display_issues_demo.py @ 28:e2864dabdb8c

fixes a logical error in the filtering of columns. * The columns are stored in the pure order as they appear in the config. * display_issues.py has been renamed to roundup_cc_display.py.
author Magnus Schieder <mschieder@intevation.de>
date Thu, 22 Nov 2018 12:57:20 +0100
parents 761ee2351f58
children
line wrap: on
line source
#!/usr/bin/env python3

""" Fetch issues from a roundup-tracker and save them in a databse.

author: Sascha L. Teichmann <sascha.teichmann@intevation.de>
author: Bernhard Reiter <bernhard@intevation.de>
author: Sean Engelhardt <sean.engelhardt@intevation.de>

(c) 2010, 2015, 2018 by Intevation GmbH

This is Free Software unter the terms of the
GNU GENERAL PUBLIC LICENSE Version 3 or later.
See http://www.gnu.org/licenses/gpl-3.0.txt for details
"""
import configparser
import argparse
from display_issues import *

def main():
    PRIO = "critical, urgent, bug, feature, wish"
    STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved"

    parser = argparse.ArgumentParser()
    parser.add_argument("config_file", type=str, metavar="[config file]")
    args = parser.parse_args()

    config = configparser.ConfigParser()
    config.read(args.config_file)

    db = config.get("DB", "DatabaseFile")
    keywords = config.get("SEARCH", "Keywords", fallback="")


    search = config.get("SEARCH", "Search", fallback="prio")
    if search == "prio":
        status = config.get("SEARCH", "Status", fallback="")
        columns = config.get("SEARCH", "Priority", fallback=PRIO)
        noPrio = config.get("SEARCH", "IncludeNoPrio", fallback=False)
        if noPrio:
            columns += ", None"

    elif search == "status":
        columns = config.get("SEARCH", "Status", fallback=STATES)
        status = ""

    else:
        print("Incorrect [SEARCH]Search parameter. (prio, status)")
        return

    # roundup uses a "-" in its search parameters. Sql can't handle it.
    columns = columns.replace("-", "_")

    cgitb.enable() # (optional) HTML traceback to browser
    #render_db_stats_as_html("./demo1.db", rcd.SELECT_ALL)
    render_db_stats_as_html(db,
            rcd.build_sql_select(columns).format("timestamp > date('now', '-2 month')"),
            columns, status, keywords)

if __name__ == '__main__':
    main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)