Exemplo 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
Exemplo n.º 2
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
Exemplo 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']))
Exemplo n.º 4
0
def gettext(s):
    """
    gettext() gets around XBMCs cryptic "Ints For Strings" translation mechanism
    requires the translatable table is kept up to date with the contents of strings.po
    """
    translatable = {"Observation Location" : 32000,
                    "Forecast Location": 32001,
                    "Regional Location": 32002,
                    "API Key": 32003,
                    "Use IP address to determine location": 32004,
                    "GeoIP Provider": 32005,
                    "Erase Cache": 32006,
                    "No API Key.": 32007,
                    "Enter your Met Office API Key under settings.": 32008,
                    "No Matches": 32009,
                    "No locations found containing": 32010,
                    "Matching Sites": 32011}
    try:
        translation = ADDON.getLocalizedString(translatable[s]) #@UndefinedVariable
        if not translation:
            raise TranslationError
        else:
            return translation
    except (KeyError, TranslationError):
        log('String "{0}" not translated.'.format(s), level=xbmc.LOGWARNING)
        return s
Exemplo n.º 5
0
def gettext(s):
    """
    gettext() gets around XBMCs cryptic "Ints For Strings" translation mechanism
    requires the translatable table is kept up to date with the contents of strings.po
    """
    translatable = {
        "Observation Location": 32000,
        "Forecast Location": 32001,
        "Regional Location": 32002,
        "API Key": 32003,
        "Use IP address to determine location": 32004,
        "GeoIP Provider": 32005,
        "Erase Cache": 32006,
        "No API Key.": 32007,
        "Enter your Met Office API Key under settings.": 32008,
        "No Matches": 32009,
        "No locations found containing": 32010,
        "Matching Sites": 32011
    }
    try:
        translation = ADDON.getLocalizedString(
            translatable[s])  #@UndefinedVariable
        if not translation:
            raise TranslationError
        else:
            return translation
    except (KeyError, TranslationError):
        log('String "{0}" not translated.'.format(s), level=xbmc.LOGWARNING)
        return s
Exemplo n.º 6
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
Exemplo n.º 7
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']))
Exemplo n.º 8
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