#!/usr/bin/python3 """Updates the wrsledrunjsoncache table (by calling wrpylib.wrmwcache.update_wrsledrunjsoncache()). Command line usage: $ python updatewrsledrunjsoncache.py inifile1.ini ... One or more .ini configuration files can be given. At the end, the following entries have to be present: [mysql] host=localhost dbname=philipp_winterrodeln_wiki user_name=philipp_www user_pass=YYYYYY [robot] wikiurl=https://www.winterrodeln.org/mediawiki/api.php """ import argparse import configparser import urllib.parse from sqlalchemy.engine import create_engine import wrpylib.wrmwcache def update_wrsledrunjsoncache(inifile): """ :param inifile: filename of an .ini file or a list of .ini files. """ config = configparser.ConfigParser() config.read(inifile) host = config.get('mysql', 'host') dbname = config.get('mysql', 'dbname') user = config.get('mysql', 'user_name') passwd = config.get('mysql', 'user_pass') engine = create_engine(f'mysql://{user}@{host}:3306/{dbname}?passwd={passwd}&charset=utf8mb4') api_url = urllib.parse.urlparse(config.get('robot', 'wikiurl')) wrpylib.wrmwcache.update_wrsledrunjsoncache(api_url, engine.connect()) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Updates the wrsledrunjsoncache table.') parser.add_argument('inifile', nargs='+', help='inifile.ini, see: https://www.winterrodeln.org/trac/wiki/ConfigIni') args = parser.parse_args() update_wrsledrunjsoncache(args.inifile)