Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-03-16 17:45:27

From: France, Vesoul
Registered: 2009-02-20
Posts: 44

weather pipemenu .fr parse error ?

well ! I'll try to be clear, net and accurate in the Shakespeare language !

try this in your urlbar :
you get a clear, net and accurate xml with my weather-forecasts, in french & C°

see my pipemenu command :

python ~/.config/openbox/scripts/ vesoul

see now my ~/.config/openbox/scripts/


import sys
import urllib
from string import maketrans
#from xml.sax import make_parser, handler
from xml.sax import handler, parseString
class ElementProcesser(handler.ContentHandler):
    def startElement(self, name, attrs):
        if name == "city":
            print "<separator label='" + attrs["data"] + "' />"
        elif name == "current_conditions":
            print "<separator label='Actuel' />"
        elif name == "condition":
            print "<item label='Weather: " + attrs["data"] + "' />"
        elif name == "humidity":
            print "<item label='" + attrs["data"] + "' />"
        elif name == "wind_condition":
            print "<item label='" + attrs["data"] + "' />"
        elif name == "day_of_week":
            print "<separator label='" + self.getDayOfWeek(attrs["data"]) + "' />"
        elif name == "temp_c":
            print "<item label='Temperature " + attrs["data"] + " C' />"
        elif name == "low":
            print "<item label='Minimun " + attrs["data"] + " C' />"
        elif name == "high":
            print "<item label='Maximun " + attrs["data"] + " C' />"
        #elif name == "temp_f":
            #print "<item label='Temperature " + attrs["data"] + " F' />"
        #elif name == "low":
            #print "<item label='Minimun " + attrs["data"] + " F' />"
        #elif name == "high":
            #print "<item label='Maximun " + attrs["data"] + " F' />"
    def endElement(self, name):
        if name == "current_conditions":
            print "<separator label='Forecast' />"
    def startDocument(self):
        print '<openbox_pipe_menu>'
    def endDocument(self):
        print '</openbox_pipe_menu>'
    def getDayOfWeek(self,day):
        if day == "Mon":
            return "Monday"
        elif day == "Tue":
            return "Tuesday"
        elif day == "Wed":
            return "Wednesday"
        elif day == "Thu":
            return "Thursday"
        elif day == "Sat":
            return "Saturday"
        elif day == "Sun":
            return "Sunday"
            return day

# You should use your local version of google to have the messages in your language and metric system
f = urllib.urlopen(""+sys.argv[1])
xml =

#Avoid problems with non english characters
xml = xml.translate(trans)


correct, no ?
but I get sometimes no pipemenu or sometimes this alert

the only way for me to get a forecast in C° is to connext to (Netherlands)

I do love my some nl-friends, I know that Onbewolk means 'nuageux' but where is the problem ?
thanks for your help


Help fund CrunchBang, donate to the project!

#2 2009-03-25 22:08:41

Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 600

Re: weather pipemenu .fr parse error ?


* Il y'a un prob dans le format on dirait .. Il commence bien la sortie, mais il bug sur la fin ..

david@acer-desktop:~$ python vesoul
<separator label='Vesoul, Franche-Comte' />
<separator label='Actuel' />
<item label='Weather: Nuageux dans l'ensemble' />
<item label='Temperature 4 C' />
<item label='Humidite : 100%' />
Traceback (most recent call last):
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:597: not well-formed (invalid token)

et google me dit :

xml.sax._exceptions.SAXParseException: <unknown>:x:y: not well-formed ...

Despite the best efforts of the preParsers there is badly formed XML within the document; possibly a malformed tag, or character entity.
ACTION: Check the document source at line x, column y.

après un petit test , c'est le " à " dans cette ligne :

<wind_condition data="Vent : O à 23 km/h"/>

Solution , remplace cette ligne dans ton script :


par celle-ci ( simple ajout de la conversion 'à' -> 'a' )


Bien à toi , @pluche

David [aka] ADcomp


Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo