Temperature and wind information for your location on a PiFace display

A really simple script, hopefully self explanatory, to get your current location and display some weather data on the PiFace. I’ve got this running as a cronjob every hour.

NOTE: requires that you get yourself an API key from the met office from here; http://www.metoffice.gov.uk/datapoint

NOTE: this script doesn’t handle exceptions, it just ignores them. 


# Reads data from the met office for our location and displays the temperature and wind-speed on the PiFace


import pifacecad

import metoffer

import urllib

import xml.etree.ElementTree as ET



# get our IP address

url = ‘http://checkip.dyndns.org’

response = urllib.urlopen(url)

htmlData = response.read()

startTag = ‘Address: ‘

ipaddress = htmlData[htmlData.find(startTag)+len(startTag):htmlData.find(‘</body’)]

print ‘External IP address is: ‘ + ipaddress


# get our latitude and longtitude (based on IP address)

url = ‘http://freegeoip.net/xml/’+ipaddress

response = urllib.urlopen(url)

tree = ET.fromstring(response.read())

latitude = tree.find(‘Latitude’).text

longtitude = tree.find(‘Longitude’).text


print ‘Geolocation: ‘ + latitude + ‘:’ + longtitude


# initialize PiFace and met office API

pfcad = pifacecad.PiFaceCAD()

met_api_key = ‘YOUR-API-KEY-HERE’

met = metoffer.MetOffer(met_api_key)


# get local weather

weather_observations = met.nearest_loc_obs(float(latitude),float(longtitude))


# Info on metoffer data: https://pypi.python.org/pypi/MetOffer/

weather_report = metoffer.parse_val(weather_observations)

# last item is the latest observation data

weather_data = weather_report.data[len(weather_report.data)-1]


# Update PiFace display

#info on PiFace http://piface.github.io/pifacecad/example.html



wind_info = weather_data[‘Wind Speed’]

wind_direction = weather_data[‘Wind Direction’]

pfcad.lcd.write(str(wind_info[0])+’ ‘+wind_info[1]+ ‘ from ‘+wind_direction[0])



print ‘Something went wrong…’ # ignoring exceptions 


0x800F0A12 error when installing Win 7 SP 1 on dual boot machine

Here’s what I’ve got
  • I have a machine with two hard disks; on one there’s a Fedora (15) install and on the other Windows 7
  • I’ve got Grub set up to allow me to boot from either
And here’s the problem
  • The other day I fired up my Windows 7 install for the first time in a loong time and it wanted to install Service Pack 1 (SP1)
  • The install failed with nothing but an “0x800F0A12” message…not very helpful
The fix
The problem (as I found out from here) is that the service pack install requires the active boot partition to be the one with the Windows 7 install on. In my set up that partition is where the Grub loader lives so when the install checks the active partition it fails.
The article I’ve linked to outlines a solution involving the use of the Disk Management tool and DISKPART utility but there’s a simpler way to do this (at least in my situation).
  • Open the Disk Management tool (Computer->Manage->Disk Management)
  • Select the Disk/Partition on which your Windows install resides
    • In my case this was on Disk 1, Disk 0 was where the Grub loader and Fedora installs lived.
    • NOTE: The Disk Management tool will show which partition is “Active” and, since you’ve got the error, that will not be the one where Windows 7 lives. Check this: if your Windows 7 partition is Active and you still get the error then there’s something else going on…
  • Mark it as “active” by right clicking on it and selecting “Mark Partition as Active
  • You’re done
You will now have TWO (2) partitions active; one which is the one you had from before and one which is where Windows 7 lives. It doesn’t matter if you’ve got two, all the “marking as active” operation does is to inform the firmware that the partition can be booted from, not that it will
You can now proceed to install the Service Pack 1.
In my case it all worked.