def temperaturePrint(something): response = None temp_txt = "" rain_prob_txt = "" sunshine_length_txt = "" wind_txt = "" api = WetterQueryApi("12099", "16156188") try: response = api.call() temp_txt = response.temp + "C" rain_prob_txt = response.rain + "mm" sunshine_length_txt = response.sun + "h" wind_txt = response.wind + "km/h" except: None else: None weather_txt = "sun: " + sunshine_length_txt + " rain: " + rain_prob_txt + " temp: " + temp_txt + " wind: " + wind_txt terminalSize = os.popen('stty size', 'r').read().split() terminalHeight = int(terminalSize[0]) terminalWidth = int(terminalSize[1]) curses.init_pair(1, curses.COLOR_YELLOW, curses.COLOR_BLACK) screen.addstr(terminalHeight-1,terminalWidth-len(weather_txt)-1,weather_txt, curses.color_pair(1)) if type(something) == 'str': screen.addstr(terminalHeight-1,0, something) else: screen.addstr(terminalHeight-1,0,str(something)) screen.refresh()
def clean(str): return re.search('-?[0-9]+[.]?[0-9]+',str).group(0) from wetter24grabber.api.queryapi import WetterQueryApi api = WetterQueryApi("12099", "16156188") response = api.call() re.search('-?[0-9]+[.][0-9]+',response.temp).group(0)