Mercurial > roundup-cc
view roundup_cc.py @ 31:9aca070c86bd
Add the filter 'priority' for the search by status.
author | Magnus Schieder <mschieder@intevation.de> |
---|---|
date | Thu, 22 Nov 2018 19:34:53 +0100 |
parents | e2864dabdb8c |
children | 80bbd06fe8ec |
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(", ") include_no_prio = config.getboolean("SEARCH", "IncludeNoPrio", fallback= False) search = config.get("SEARCH", "Search", fallback="prio") if search == "prio": list_of_columns = config.get("SEARCH", "Priority", fallback=PRIO).split(", ") search_parameters = config.get("SEARCH", "Status", fallback="").split(", ") if include_no_prio: list_of_columns += ["None"] elif search == "status": list_of_columns = config.get("SEARCH", "Status", fallback=STATES).split(", ") # statsu = columns Must change search_parameters = config.get("SEARCH", "Priority", fallback="").split(", ") if include_no_prio: search_parameters += ["None"] else: print("Incorrect [SEARCH]Search parameter. (prio, status)") return # roundup uses a "-" in its search parameters. Sql can't handle it. sql_list_of_columns = [] for column in list_of_columns: sql_list_of_columns.append(column.replace("-", "_")) select_all, select_where, create_db, insert_new = \ rcd.build_sql_commands(sql_list_of_columns) save_stats_in_db(search, login_parameters, base_url, database_file, list_of_columns, create_db, insert_new, keywords, search_parameters, include_no_prio) if __name__ == '__main__': main()