view roundup_cc.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
line wrap: on
line source
#!/usr/bin/env python3
"""Connect to roundup-tracker and save status to db.

Run periodically as often as you want data points to be saved.
"""

import configparser
import argparse

from collect_issues import save_stats_in_db
import roundup_content_data as rcd

PRIO = "critical, urgent, bug, feature, wish"
STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved"

def main():

    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)

    base_url = config.get("URL", "BaseURL")

    user = config.get("LOGIN","Username")
    password = config.get("LOGIN", "Password")

    login_parameters = (
        ("__login_name", user),
        ("__login_password", password),
        ("@action", "Login"),
        )

    database_file = config.get("DB", "DatabaseFile")

    keywords = config.get("SEARCH", "Keywords", fallback="").split(", ")

    search = config.get("SEARCH", "Search", fallback="prio")
    if search == "prio":
        list_of_columns = config.get("SEARCH", "Priority", fallback=PRIO).split(", ")
        status = config.get("SEARCH", "Status", fallback="").split(", ")
        include_no_prio = config.getboolean("SEARCH", "IncludeNoPrio", fallback= False)
        if include_no_prio:
            list_of_columns += ["None"]

    elif search == "status":
        list_of_columns = config.get("SEARCH", "Status", fallback=STATES).split(", ")
        status = [""]

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

    select_all, select_where, create_db, insert_new = \
        rcd.build_sql_commands(list_of_columns)

    save_stats_in_db(search, login_parameters, base_url, database_file,
                    list_of_columns, create_db, insert_new, keywords, status)

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