mschieder@25: #!/usr/bin/env python3 mschieder@25: """Connect to roundup-tracker and save status to db. mschieder@25: mschieder@25: Run periodically as often as you want data points to be saved. mschieder@25: """ mschieder@25: mschieder@25: import configparser mschieder@25: import argparse mschieder@25: mschieder@25: from collect_issues import save_stats_in_db mschieder@25: import roundup_content_data as rcd mschieder@25: mschieder@25: PRIO = "critical, urgent, bug, feature, wish" mschieder@25: STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved" mschieder@25: mschieder@25: def main(): mschieder@25: mschieder@25: parser = argparse.ArgumentParser() mschieder@25: parser.add_argument("config_file", type=str, metavar="[config file]") mschieder@25: args = parser.parse_args() mschieder@25: mschieder@25: config = configparser.ConfigParser() mschieder@25: config.read(args.config_file) mschieder@25: mschieder@25: base_url = config.get("URL", "BaseURL") mschieder@25: mschieder@25: user = config.get("LOGIN","Username") mschieder@25: password = config.get("LOGIN", "Password") mschieder@25: mschieder@25: login_parameters = ( mschieder@25: ("__login_name", user), mschieder@25: ("__login_password", password), mschieder@25: ("@action", "Login"), mschieder@25: ) mschieder@25: mschieder@25: database_file = config.get("DB", "DatabaseFile") mschieder@25: mschieder@25: keywords = config.get("SEARCH", "Keywords", fallback="").split(", ") mschieder@25: mschieder@25: search = config.get("SEARCH", "Search", fallback="prio") mschieder@25: if search == "prio": mschieder@25: list_of_columns = config.get("SEARCH", "Columns", fallback=PRIO).split(", ") mschieder@25: status = config.get("SEARCH", "Status", fallback="").split(", ") mschieder@25: include_no_prio = config.getboolean("SEARCH", "IncludeNoPrio", fallback= False) mschieder@25: if include_no_prio: mschieder@25: list_of_columns += ["None"] mschieder@25: mschieder@25: elif search == "status": mschieder@25: list_of_columns = config.get("SEARCH", "Status", fallback=STATES).split(", ") mschieder@25: status = [""] mschieder@25: mschieder@25: select_all, select_where, create_db, insert_new = \ mschieder@25: rcd.build_sql_commands(list_of_columns) mschieder@25: mschieder@25: save_stats_in_db(search, login_parameters, base_url, database_file, mschieder@25: list_of_columns, create_db, insert_new, keywords, status) mschieder@25: mschieder@25: if __name__ == '__main__': mschieder@25: main()