-"""Creates the image thumbnails or icons for sledruns to be used in the sledmap application.
+#!/usr/bin/python3
+"""Creates the image thumbnails or icons for sledruns to be used in the sledmap or other application.
Can be used in a python session or at the command line.
usage: createthumbnails.py [-h] {thumbnail,icon} inifile [inifile ...]
positional arguments:
{thumbnail,icon} thumbnails or icons?
inifile inifile.ini (See:
- http://www.winterrodeln.org/trac/wiki/ConfigIni)
+ https://www.winterrodeln.org/trac/wiki/ConfigIni)
optional arguments:
-h, --help show this help message and exit
sledrunicondir=/home/philipp/www/winterrodeln.org/karte/mediawiki_icons
"""
-
import argparse
-import os
import configparser
+import os
import hashlib
import MySQLdb
from PIL import Image, ImageFilter
def image_to_icon(im, width, height):
"""The icon will have a size of width times height and contains a centered sub-part of the image."""
- if im.size[0]/float(width) > im.size[1]/float(height):
+ if im.size[0] / float(width) > im.size[1] / float(height):
# scale image to height
- im.thumbnail((int(round(im.size[0]*im.size[1]/height)), height), Image.ANTIALIAS)
+ im.thumbnail((int(round(im.size[0] * im.size[1] / height)), height), Image.ANTIALIAS)
# crop image (left, upper, right (excl), lower (excl))
- left = (im.size[0]-width)//2
- im = im.crop((left, 0, left+width, height))
+ left = (im.size[0] - width) // 2
+ im = im.crop((left, 0, left + width, height))
else:
# scale image to width
- im.thumbnail((width, int(round(im.size[1]*im.size[0]/width))), Image.ANTIALIAS)
+ im.thumbnail((width, int(round(im.size[1] * im.size[0] / width))), Image.ANTIALIAS)
# crop image (left, upper, right (excl), lower (excl))
- upper = (im.size[1]-height)//2
- im = im.crop((0, upper, width, upper+height))
+ upper = (im.size[1] - height) // 2
+ im = im.crop((0, upper, width, upper + height))
# sharpen
im = im.filter(ImageFilter.SHARPEN)
return im
mcon.close()
-if __name__=='__main__':
- parser = argparse.ArgumentParser(description='Creates the image thumbnails or icons for sledruns to be used in the sledmap application.')
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(
+ description='Creates the image thumbnails or icons for sledruns to be used in the sledmap application.')
parser.add_argument('type', choices=['thumbnail', 'icon'], help='thumbnails or icons?')
- parser.add_argument('inifile', nargs='+', help='inifile.ini (See: http://www.winterrodeln.org/trac/wiki/ConfigIni)')
+ parser.add_argument('inifile', nargs='+', help='inifile.ini, see: https://www.winterrodeln.org/trac/wiki/ConfigIni')
args = parser.parse_args()
update_image_dir_by_inifile(args.inifile, args.type)
+#!/usr/bin/python3
import argparse
import configparser
import datetime
-"""Updates the wrsledrun table (by calling wrpylib.wrmwcache.update_wrinncache()).
+#!/usr/bin/python3
+"""Updates the wrinncache table (by calling wrpylib.wrmwcache.update_wrinncache()).
Can be used in a python session or at the command line.
Command line usage:
user_name=philipp_www
user_pass=YYYYYY
"""
-
-import sys
+import argparse
import configparser
from sqlalchemy.engine import create_engine
import wrpylib.wrmwcache
user = config.get('mysql', 'user_name')
passwd = config.get('mysql', 'user_pass')
- engine = create_engine('mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=0'.format(host=host, dbname=dbname, user=user, passwd=passwd))
+ engine = create_engine(f'mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=0')
# "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')
+ parser = argparse.ArgumentParser(description='Updates the wrinncache table.')
+ parser.add_argument('inifile', nargs='+', help='inifile.ini, see: https://www.winterrodeln.org/trac/wiki/ConfigIni')
+ args = parser.parse_args()
+ update_wrinncache(args.inifile)
+#!/usr/bin/python3
"""Updates the wrmappathcache and wrmappointcache tables (by calling wrpylib.wrmwcache.update_wrmapcache()).
Can be used in a python session or at the command line.
user_name=philipp_www
user_pass=YYYYYY
"""
-
-import sys
+import argparse
import configparser
from sqlalchemy.engine import create_engine
import wrpylib.wrmwcache
user = config.get('mysql', 'user_name')
passwd = config.get('mysql', 'user_pass')
- engine = create_engine('mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=0'.format(host=host, dbname=dbname, user=user, passwd=passwd))
+ engine = create_engine(f'mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=0')
# "use_unicode=0": see: https://sourceforge.net/tracker/?func=detail&aid=2837134&group_id=22307&atid=374932
wrpylib.wrmwcache.update_wrmapcache(engine.connect())
if __name__ == '__main__':
- if len(sys.argv) >= 2:
- update_wrmapcache(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')
-
+ parser = argparse.ArgumentParser(description='Updates the wrmappathcache and wrmappointcache tables.')
+ parser.add_argument('inifile', nargs='+', help='inifile.ini, see: https://www.winterrodeln.org/trac/wiki/ConfigIni')
+ args = parser.parse_args()
+ update_wrmapcache(args.inifile)
+#!/usr/bin/python3
"""
usage: updatewrregioncache.py [-h] inifile [inifile ...]
positional arguments:
inifile inifile.ini (See:
- http://www.winterrodeln.org/trac/wiki/ConfigIni)
+ https://www.winterrodeln.org/trac/wiki/ConfigIni)
optional arguments:
-h, --help show this help message and exit
user = config.get('mysql', 'user_name')
passwd = config.get('mysql', 'user_pass')
- engine = create_engine('mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=1'.format(host=host, dbname=dbname, user=user, passwd=passwd))
+ engine = create_engine(f'mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=1')
wrpylib.wrmwcache.update_wrregioncache(engine.connect())
if __name__=='__main__':
- parser = argparse.ArgumentParser(description='Updates the wrregioncache table (by calling wrpylib.wrmwcache.update_wrregioncache()).')
- parser.add_argument('inifile', nargs='+', help='inifile.ini (See: http://www.winterrodeln.org/trac/wiki/ConfigIni)')
+ parser = argparse.ArgumentParser(description='Updates the wrregioncache table.')
+ parser.add_argument('inifile', nargs='+', help='inifile.ini, see: https://www.winterrodeln.org/trac/wiki/ConfigIni')
args = parser.parse_args()
update_wrregioncache(args.inifile)
+#!/usr/bin/python3
"""Updates the wrreportcache table (by calling wrpylib.wrmwcache.update_wrreportcache()).
Can be used in a python session or at the command line.
user_name=philipp_www
user_pass=YYYYYY
"""
-
-import sys
+import argparse
import configparser
from sqlalchemy.engine import create_engine
import wrpylib.wrmwcache
user = config.get('mysql', 'user_name')
passwd = config.get('mysql', 'user_pass')
- engine = create_engine('mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=1'.format(host=host, dbname=dbname, user=user, passwd=passwd))
+ engine = create_engine(f'mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=1')
# "use_unicode=1": see: https://sourceforge.net/tracker/?func=detail&aid=2837134&group_id=22307&atid=374932
wrpylib.wrmwcache.update_wrreportcache(engine.connect())
if __name__ == '__main__':
- if len(sys.argv) >= 2:
- update_wrreportcache(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')
+ parser = argparse.ArgumentParser(description='Updates the wrreportcache table.')
+ parser.add_argument('inifile', nargs='+', help='inifile.ini, see: https://www.winterrodeln.org/trac/wiki/ConfigIni')
+ args = parser.parse_args()
+ update_wrreportcache(args.inifile)
-"""Updates the wrsledrun table (by calling wrpylib.wrmwcache.update_wrsledruncache()).
+#!/usr/bin/python3
+"""Updates the wrsledruncache table (by calling wrpylib.wrmwcache.update_wrsledruncache()).
Can be used in a python session or at the command line.
Command line usage:
user_name=philipp_www
user_pass=YYYYYY
"""
-
-import sys
+import argparse
import configparser
from sqlalchemy.engine import create_engine
import wrpylib.wrmwcache
user = config.get('mysql', 'user_name')
passwd = config.get('mysql', 'user_pass')
- engine = create_engine('mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=0'.format(host=host, dbname=dbname, user=user, passwd=passwd))
+ engine = create_engine(f'mysql://{user}@{host}:3306/{dbname}?charset=utf8&passwd={passwd}&use_unicode=0')
# "use_unicode=0": see: https://sourceforge.net/tracker/?func=detail&aid=2837134&group_id=22307&atid=374932
wrpylib.wrmwcache.update_wrsledruncache(engine.connect())
if __name__ == '__main__':
- if len(sys.argv) >= 2:
- update_wrsledruncache(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')
+ parser = argparse.ArgumentParser(description='Updates the wrsledruncache table.')
+ parser.add_argument('inifile', nargs='+', help='inifile.ini, see: https://www.winterrodeln.org/trac/wiki/ConfigIni')
+ args = parser.parse_args()
+ update_wrsledruncache(args.inifile)