Giter VIP home page Giter VIP logo

weather.metoffice's Introduction

weather.metoffice Codeship Status

Weather plugin for Kodi. Fetches data from the UK Met Office.

Development and Testing

Create a virtual env.

python -m venv .venv

Activate the virtual env.

source .venv/bin/activate

Install dependencies.

pip install -r requirements.txt

Run tests.

python -m unittest discover

Deployment

Code is "deployed" by creating a PR against the repo-scripts repository.

weather.metoffice's People

Contributors

powlo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

weather.metoffice's Issues

Bug: "Feels Like" Temp Wrong & Missing Provider Logo

In testing various Kodi weather providers for a skin feature change I noticed the following with the Met Office Kodi weather provider:

"feels like" weather temp was obviously not right and the weather provider logo wasn't being displayed (missing).

2015-04-26_14-36-41

Kodi Nexus 20 module 'xbmc' has no attribute 'translatePath'

Full log shows:

 EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
  - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
 Error Type: <class 'AttributeError'>
 Error Contents: module 'xbmc' has no attribute 'translatePath'
 Traceback (most recent call last):
   File "/storage/.kodi/addons/weather.metoffice/src/setlocation.py", line 12, in <module>
     from metoffice import utilities, urlcache
   File "/storage/.kodi/addons/weather.metoffice/src/metoffice/utilities.py", line 9, in <module>
     from .constants import WEATHER_WINDOW_ID, ADDON_BROWSER_WINDOW_ID, DIALOG, WINDOW, TEMPERATUREUNITS, ADDON
   File "/storage/.kodi/addons/weather.metoffice/src/metoffice/constants.py", line 21, in <module>
     ADDON_BANNER_PATH = xbmc.translatePath('special://home/addons/%s/resources/banner.png' % ADDON.getAddonInfo('id'))
                         ^^^^^^^^^^^^^^^^^^
 AttributeError: module 'xbmc' has no attribute 'translatePath'
 -->End of Python script error report<--

The fix is exactly as here:
melmorabity/plugin.video.francetv#4

Just edit /storage/.kodi/addons/weather.metoffice/src/metoffice/constants.py

add, where the existing imports are:

import xbmcvfs

and, lines 22 & 23, change

ADDON_BANNER_PATH = xbmc.translatePath('special://home/addons/%s/resources/banner.png' % ADDON.getAddonInfo('id'))
ADDON_DATA_PATH = xbmc.translatePath('special://profile/addon_data/%s/' % ADDON.getAddonInfo('id'))

to

ADDON_BANNER_PATH = xbmcvfs.translatePath('special://home/addons/%s/resources/banner.png' % ADDON.getAddonInfo('id'))
ADDON_DATA_PATH = xbmcvfs.translatePath('special://profile/addon_data/%s/' % ADDON.getAddonInfo('id'))

ImportError: No module named PIL

Hi,

I've recently tried to install your plugin onto my fresh installation of RaspBMC. When I try it tries to update the weather forecast I get a script error reported, and I see the following in the logs:

09:39:31 T:2900001856 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.ImportError'>
Error Contents: No module named PIL
Traceback (most recent call last):
File "/home/pi/.kodi/addons/weather.metoffice/src/metoffice/default.py", line 21, in
import utilities, properties, urlcache
File "/home/pi/.kodi/addons/weather.metoffice/src/metoffice/properties.py", line 6, in
from PIL import Image
ImportError: No module named PIL
-->End of Python script error report<--

Any idea?

'Location' key not found in JSON.

Error : KeyError: ('Key Error in JSON File', "Key 'Location' not found while processing file from url:", 'http://datapoint.metoffice.gov.uk/public/data/val/wxobs/all/json/3351?res=hourly&key=a69bbf86-54dd-427f-b48d-0e260a76c2f5')

When viewing the Weather page. The error is fairly self explanatory, the JSON it's looking at looks like this:

{"SiteRep":{"Wx":{"Param":[{"name":"G","units":"mph","$":"Wind Gust"},{"name":"T","units":"C","$":"Temperature"},{"name":"V","units":"m","$":"Visibility"},{"name":"D","units":"compass","$":"Wind Direction"},{"name":"S","units":"mph","$":"Wind Speed"},{"name":"W","units":"","$":"Weather Type"},{"name":"P","units":"hpa","$":"Pressure"},{"name":"Pt","units":"Pa/s","$":"Pressure Tendency"},{"name":"Dp","units":"C","$":"Dew Point"},{"name":"H","units":"%","$":"Screen Relative Humidity"}]},"DV":{"dataDate":"2014-05-06T16:00:00Z","type":"Obs"}}}

Metoffice rejecting python-2.7

I'm getting error 403 responses from the metoffice site.
Testing with 'wget' shows that they respond with 403 if the htp User-Agent is 'Python-urllib-2.7' but anything else (even 'Wget/1.18') works OK.
I've worked around this by patching urlcache.py: change
response = urllib2.urlopen(url)
to
opener = urllib2.build_opener()
opener.addheaders = [('User-Agent', 'Mozilla/5.0')]
response = opener.open(url)
opener.close()
Not a python expert, so not sure if this is correct.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.