- ComputeSleepy.py (relies on the sumpoints) Script stops if one of the processes has non-zero exit state. """ import sys, os from pywetterturnier import utils, database import numpy as np # - Store input arguments - need them later # to call the subscripts. Only for the Chain.py script. main_args = sys.argv[1:] # - Evaluating input arguments inputs = utils.inputcheck('Chain') # - Read configuration file config = utils.readconfig('config.conf', inputs) # - Initializing class and open database connection db = database.database(config) current_tdate = db.current_tournament() today = utils.today_tdate() # - Loading tdate (day since 1970-01-01) for the tournament. # Normaly Friday-Tornament (tdate is then Friday) while # the bet-dates are for Saturday and Sunday. is_latest_tournament = False if config['input_tdate'] == None: config['input_tdate'] = current_tdate print ' * Using latest tournament date: %d' % config['input_tdate'] is_latest_tournament = True else:
# - Missing input -o if not inputs.param: print parser.usage utils.exit("Missing required input -p/--param.") if not inputs.obs: print parser.usage utils.exit("Missing required input -o/--obs.") if not inputs.values: print parser.usage utils.exit("Missing required input -v/--values.") # ---------------------------------------------------------------- # ---------------------------------------------------------------- # - Reading config file # ---------------------------------------------------------------- config = utils.readconfig('config.conf') # ---------------------------------------------------------------- # - Checking if parameter is allowed # ---------------------------------------------------------------- from pywetterturnier import database if not inputs.quiet: print " * Checking if parameter %s is allowed" % inputs.param db = database.database(config) paramID = db.get_parameter_id(inputs.param) db.close(False) if not paramID: utils.exit("[!] Parameter %s unknown! Stop." % inputs.param) # ---------------------------------------------------------------- # - Helper function: comma separated inuts to numpy arrays
from pywetterturnier.utils import nicename # Some MOS systems have been renamed. Loading conversion table. fid = open("data/MOSrenaming.txt", "r") conversion_table = {} for line in fid.readlines(): if line.strip()[0] == "#": continue line = line.split(";") conversion_table[nicename(line[1].strip())] = nicename(line[0].strip()) print line[1].strip(), nicename(line[1].strip()) print " - Old: %-20s New: %-20s" % (nicename( line[1]), nicename(line[0])) # - Reading configuration file first inputs = utils.inputcheck('archive') config = utils.readconfig(inputs=inputs, conversion_table=conversion_table) # ---------------------------------------------------------------- # - Because of the observations we have to compute the # points city by city. Loading city data here first. # ---------------------------------------------------------------- from pywetterturnier import database # - Initializing class and open database connection db = database.database(config) # - Loading all different cities (active cities) cities = db.get_cities() # - If input city set, then drop all other cities. if not config['input_city'] == None: tmp = [] for elem in cities:
# - Wetterturnier specific modules from pywetterturnier import utils from pywetterturnier import importbets try: opts, args = getopt.getopt(sys.argv[1:],'-o',['--obs']) except getopt.GetoptError as err: print(err) utils.exit('Wrong input options set') obsonly = False for o, a in opts: if o in ['-o','--obs']: obsonly = True # - Reading configuration file first config = utils.readconfig() # - The url needed to download the data url_template = 'http://wetterturnier.de/wertungen/uebersicht_%s.php?p=ue0&stadt=%s' # --------------------------------------------------------------- # - No tags? No downloading shit. if config['migrate_citytags'] == None: print ' * No citytags from config file: nothing will be done.' # --------------------------------------------------------------- # - Else going trough and downloading the current wetterturnier # bets. else: print ' * %s' % 'Downloading current bets now'