#!/usr/bin/python2.7 # -*- coding: iso-8859-15 -*- """Updates the wrsledrun table (by calling wrpylib.wrmwcache.update_wrinncache()). Can be used in a python session or at the command line. Command line usage: $ python updatewrinncache.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 """ import sys import ConfigParser from sqlalchemy.engine import create_engine import wrpylib.wrmwcache def update_wrinncache(inifile): """ :param inifile: filename of an .ini file or a list of .ini files. """ config = ConfigParser.SafeConfigParser() 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(u'mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=0'.format(host=host, dbname=dbname, user=user, passwd=passwd)) # "use_unicode=0": see: https://sourceforge.net/tracker/?func=detail&aid=2837134&group_id=22307&atid=374932 wrpylib.wrmwcache.update_wrinncache(engine.connect()) if __name__ == '__main__': if len(sys.argv) >= 2: update_wrinncache(sys.argv[1:]) else: print 'Usage:\n{0} infile1.ini [inifile2.ini ...]'.format(sys.argv[0]) print 'See: http://www.winterrodeln.org/trac/wiki/ConfigIni'