def main(location): if not API_KEY: raise Exception(_("No API Key."), _("Enter your Met Office API Key under settings.")) KEYBOARD.doModal() #@UndefinedVariable text = KEYBOARD.isConfirmed() and KEYBOARD.getText() #@UndefinedVariable sitelist = getsitelist(location, text) if sitelist == []: DIALOG.ok(_("No Matches"), _("No locations found containing") + " {0}".format(text)) #@UndefinedVariable utilities.log("No locations found containing '%s'" % text) else: display_list = [site['display'] for site in sitelist] selected = DIALOG.select(_("Matching Sites"), display_list) #@UndefinedVariable if selected != -1: ADDON.setSetting(location, sitelist[selected]['name']) #@UndefinedVariable ADDON.setSetting("%sID" % location, sitelist[selected]['id']) #@UndefinedVariable ADDON.setSetting( "%sLatitude" % location, str(sitelist[selected].get('latitude'))) #@UndefinedVariable ADDON.setSetting( "%sLongitude" % location, str(sitelist[selected].get('longitude'))) #@UndefinedVariable utilities.log( "Setting '{location}' to '{name} ({distance})'".format( location=location, name=sitelist[selected]['name'].encode('utf-8'), distance=sitelist[selected]['id']))
def wrapper(*args, **kwds): try: return f(*args, **kwds) except Exception as e: e.args = map(str, e.args) log(traceback.format_exc(), xbmc.LOGSEVERE) if len(e.args) == 0 or e.args[0] == '': e.args = ('Error',) if len(e.args) == 1: e.args = e.args + ('See log file for details',) if xbmcgui.getCurrentWindowId() == WEATHER_WINDOW_ID or xbmcgui.getCurrentWindowId() == SETTINGS_WINDOW_ID: args = (e.args[0].title(),) + e.args[1:4] DIALOG.ok(*args)#@UndefinedVariable
def wrapper(*args, **kwds): try: return f(*args, **kwds) except Exception as e: e.args = map(str, e.args) log(traceback.format_exc(), xbmc.LOGSEVERE) if len(e.args) == 0 or e.args[0] == '': e.args = ('Error', ) if len(e.args) == 1: e.args = e.args + ('See log file for details', ) if xbmcgui.getCurrentWindowId( ) == WEATHER_WINDOW_ID or xbmcgui.getCurrentWindowId( ) == SETTINGS_WINDOW_ID: args = (e.args[0].title(), ) + e.args[1:4] DIALOG.ok(*args) #@UndefinedVariable
def main(location): if not API_KEY: raise Exception(_("No API Key."), _("Enter your Met Office API Key under settings.")) KEYBOARD.doModal()#@UndefinedVariable text= KEYBOARD.isConfirmed() and KEYBOARD.getText()#@UndefinedVariable sitelist = getsitelist(location, text) if sitelist == []: DIALOG.ok(_("No Matches"), _("No locations found containing")+" {0}".format(text))#@UndefinedVariable utilities.log("No locations found containing '%s'" % text) else: display_list = [site['display'] for site in sitelist] selected = DIALOG.select(_("Matching Sites"), display_list)#@UndefinedVariable if selected != -1: ADDON.setSetting(location, sitelist[selected]['name'])#@UndefinedVariable ADDON.setSetting("%sID" % location, sitelist[selected]['id'])#@UndefinedVariable ADDON.setSetting("%sLatitude" % location, str(sitelist[selected].get('latitude')))#@UndefinedVariable ADDON.setSetting("%sLongitude" % location, str(sitelist[selected].get('longitude')))#@UndefinedVariable utilities.log("Setting '{location}' to '{name} ({distance})'".format(location=location, name=sitelist[selected]['name'].encode('utf-8'), distance=sitelist[selected]['id']))