Esempio n. 1
0
def main():
    if ADDON.getSetting('EraseCache') == 'true':
        try:
            urlcache.URLCache(ADDON_DATA_PATH).erase()
        finally:
            ADDON.setSetting('EraseCache', 'false')#@UndefinedVariable

    if not API_KEY:
        raise Exception(_("No API Key."), _("Enter your Met Office API Key under settings."))

    properties.observation()
    properties.daily()
    properties.threehourly()

    WINDOW.setProperty('WeatherProvider', ADDON.getAddonInfo('name'))#@UndefinedVariable
    WINDOW.setProperty('WeatherProviderLogo', ADDON_BANNER_PATH)#@UndefinedVariable
    WINDOW.setProperty('ObservationLocation', ADDON.getSetting('ObservationLocation'))#@UndefinedVariable
    WINDOW.setProperty('Current.Location', ADDON.getSetting('ForecastLocation'))#@UndefinedVariable
    WINDOW.setProperty('ForecastLocation', ADDON.getSetting('ForecastLocation'))#@UndefinedVariable
    WINDOW.setProperty('RegionalLocation', ADDON.getSetting('RegionalLocation'))#@UndefinedVariable
    WINDOW.setProperty('Location1', ADDON.getSetting('ForecastLocation'))#@UndefinedVariable
    WINDOW.setProperty('Locations', '1')#@UndefinedVariable

    #Explicitly set unused flags to false, so there are no unusual side
    #effects/residual data when moving from another weather provider.
    WINDOW.setProperty('36Hour.IsFetched', '')#@UndefinedVariable
    WINDOW.setProperty('Weekend.IsFetched', '')#@UndefinedVariable
    WINDOW.setProperty('Map.IsFetched', '')#@UndefinedVariable
    WINDOW.setProperty('Today.Sunrise', '')#@UndefinedVariable
    WINDOW.setProperty('Today.Sunset', '')#@UndefinedVariable
    WINDOW.setProperty('Weather.CurrentView', '')#@UndefinedVariable
def main():
    if ADDON.getSetting('EraseCache') == 'true':
        try:
            urlcache.URLCache(ADDON_DATA_PATH).erase()
        finally:
            ADDON.setSetting('EraseCache', 'false')#@UndefinedVariable

    if not API_KEY:
        raise Exception(_("No API Key."), _("Enter your Met Office API Key under settings."))

    if len(sys.argv) > 1 and sys.argv[1].isdigit():
        properties.observation()
    if not CURRENT_VIEW:
        properties.daily()
    elif CURRENT_VIEW == '3hourly':
        properties.threehourly()
    elif CURRENT_VIEW == 'forecastmap':
        properties.forecastlayer()
    elif CURRENT_VIEW == 'observationmap':
        properties.observationlayer()
    elif CURRENT_VIEW == 'text':
        properties.text()

    WINDOW.setProperty('WeatherProvider', ADDON.getAddonInfo('name'))#@UndefinedVariable
    WINDOW.setProperty('ObservationLocation', ADDON.getSetting('ObservationLocation'))#@UndefinedVariable
    WINDOW.setProperty('ForecastLocation', ADDON.getSetting('ForecastLocation'))#@UndefinedVariable
    WINDOW.setProperty('RegionalLocation', ADDON.getSetting('RegionalLocation'))#@UndefinedVariable
    WINDOW.setProperty('Location1', ADDON.getSetting('ObservationLocation'))#@UndefinedVariable
    WINDOW.setProperty('Locations', '1')#@UndefinedVariable
Esempio n. 3
0
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']))
Esempio n. 4
0
def main():
    if ADDON.getSetting('EraseCache') == 'true':
        try:
            urlcache.URLCache(ADDON_DATA_PATH).erase()
        finally:
            ADDON.setSetting('EraseCache', 'false')  #@UndefinedVariable

    if not API_KEY:
        raise Exception(_("No API Key."),
                        _("Enter your Met Office API Key under settings."))

    properties.observation()
    properties.daily()
    properties.threehourly()

    WINDOW.setProperty('WeatherProvider',
                       ADDON.getAddonInfo('name'))  #@UndefinedVariable
    WINDOW.setProperty('WeatherProviderLogo',
                       ADDON_BANNER_PATH)  #@UndefinedVariable
    WINDOW.setProperty(
        'ObservationLocation',
        ADDON.getSetting('ObservationLocation'))  #@UndefinedVariable
    WINDOW.setProperty(
        'Current.Location',
        ADDON.getSetting('ForecastLocation'))  #@UndefinedVariable
    WINDOW.setProperty(
        'ForecastLocation',
        ADDON.getSetting('ForecastLocation'))  #@UndefinedVariable
    WINDOW.setProperty(
        'RegionalLocation',
        ADDON.getSetting('RegionalLocation'))  #@UndefinedVariable
    WINDOW.setProperty(
        'Location1', ADDON.getSetting('ForecastLocation'))  #@UndefinedVariable
    WINDOW.setProperty('Locations', '1')  #@UndefinedVariable

    #Explicitly set unused flags to false, so there are no unusual side
    #effects/residual data when moving from another weather provider.
    WINDOW.setProperty('36Hour.IsFetched', '')  #@UndefinedVariable
    WINDOW.setProperty('Weekend.IsFetched', '')  #@UndefinedVariable
    WINDOW.setProperty('Map.IsFetched', '')  #@UndefinedVariable
    WINDOW.setProperty('Today.Sunrise', '')  #@UndefinedVariable
    WINDOW.setProperty('Today.Sunset', '')  #@UndefinedVariable
    WINDOW.setProperty('Weather.CurrentView', '')  #@UndefinedVariable
Esempio n. 5
0
def main():
    if ADDON.getSetting('EraseCache') == 'true':
        try:
            urlcache.URLCache(ADDON_DATA_PATH).erase()
        finally:
            ADDON.setSetting('EraseCache', 'false')  #@UndefinedVariable

    if not API_KEY:
        raise Exception(_("No API Key."),
                        _("Enter your Met Office API Key under settings."))

    if len(sys.argv) > 1 and sys.argv[1].isdigit():
        properties.observation()
    if not CURRENT_VIEW:
        properties.daily()
    elif CURRENT_VIEW == '3hourly':
        properties.threehourly()
    elif CURRENT_VIEW == 'forecastmap':
        properties.forecastlayer()
    elif CURRENT_VIEW == 'observationmap':
        properties.observationlayer()
    elif CURRENT_VIEW == 'text':
        properties.text()

    WINDOW.setProperty('WeatherProvider',
                       ADDON.getAddonInfo('name'))  #@UndefinedVariable
    WINDOW.setProperty(
        'ObservationLocation',
        ADDON.getSetting('ObservationLocation'))  #@UndefinedVariable
    WINDOW.setProperty(
        'ForecastLocation',
        ADDON.getSetting('ForecastLocation'))  #@UndefinedVariable
    WINDOW.setProperty(
        'RegionalLocation',
        ADDON.getSetting('RegionalLocation'))  #@UndefinedVariable
    WINDOW.setProperty(
        'Location1',
        ADDON.getSetting('ObservationLocation'))  #@UndefinedVariable
    WINDOW.setProperty('Locations', '1')  #@UndefinedVariable
Esempio n. 6
0
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']))