diff doc/collect_demo3.py @ 34:916fa83b4144

Clean up repository. 'Update README.creole' * /doc added for the old demos. * Added comments to config.ini.
author Magnus Schieder <mschieder@intevation.de>
date Mon, 26 Nov 2018 16:08:27 +0100
parents examples/collect_demo3.py@7a523e13fcb3
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/collect_demo3.py	Mon Nov 26 16:08:27 2018 +0100
@@ -0,0 +1,52 @@
+#!/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)