view examples/collect_demo3.py @ 27:cdab667c6abb

Delete Code Duplication and Clean Up. * The search for the status does not require the "-1". * If the parameter you are looking for is not available in the tracker, an error message is issued and the program terminates, to avoid incorrect entries in the database
author Magnus Schieder <mschieder@intevation.de>
date Tue, 13 Nov 2018 21:04:22 +0100
parents 7a523e13fcb3
children
line wrap: on
line source
#!/usr/bin/env python3
"""Connect to roundup-tracker and save status to db for example demo1.

Run periodically as often as you want data points to be saved.
demo1 only tracks issues with a priority.
"""

import json
import configparser
import argparse

from collect_issues import save_stats_in_db
import roundup_content_data as rcd

COLUMNS = "critical, urgent, bug, feature, wish"

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_DEMO = (
    ("__login_name", user),
    ("__login_password", password),
    ("@action", "Login"),
    )

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

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

list_of_columns = config.get("SEARCH", "Columns", fallback=COLUMNS).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"]

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

save_stats_in_db(LOGIN_PARAMETERS_DEMO, base_url, database_file,
                list_of_columns, create_db, insert_new, keywords, status)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)