Jim Duda wrote: > Duncan Webb wrote: > >> Interesting so it look like the data has changed as the code has not >> changed for ages. >> >> Index: src/util/pymetar.py >> =================================================================== >> --- src/util/pymetar.py (revision 11576) >> +++ src/util/pymetar.py (working copy) >> @@ -834,7 +834,7 @@ >> >> elif (header == "Temperature"): >> f,i,c,i=data.split(None,3) >> - self.Report.tempf=int(f) >> + self.Report.tempf=int(float(f)) >> # The string we have split is "(NN C)", hence the slice >> self.Report.temp=int(c[1:]) >> > > I think we're just peeling the onion here ... > > Now I get:get: > > Traceback (most recent call last): > File "/usr/lib/python2.5/site-packages/freevo/plugins/idlebar/weather.py", > line 74, in run > pr = rp.ParseReport(rep) > File "/nfsroot/usr/lib/python2.5/site-packages/freevo/util/pymetar.py", > line 839, in ParseReport > self.Report.temp=int(c[1:]) > ValueError: invalid literal for int() with base 10: '10.0' > ERROR: invalid literal for int() with base 10: '10.0'
Yes of course. Two ways to solve this make the string a float and let the display decide how to display it. Change the parsing of the temp data to use a regular expression search/match. You may like to try the patches but may need to restore the original versions first. Duncan
Index: src/util/pymetar.py =================================================================== --- src/util/pymetar.py (revision 11576) +++ src/util/pymetar.py (working copy) @@ -833,10 +833,11 @@ # temperature elif (header == "Temperature"): - f,i,c,i=data.split(None,3) - self.Report.tempf=int(f) - # The string we have split is "(NN C)", hence the slice - self.Report.temp=int(c[1:]) + # data is something like: + # '62 F (17 C)' and may have decimal points + m = re.search('(\d+).* F.*\((\d+).* C\)', data) + self.Report.tempf = float(m.groups(0)) if m else -1 + self.Report.temp = float(m.groups(1)) if m else -1 # wind dir and speed
Index: src/plugins/idlebar/weather.py =================================================================== --- src/plugins/idlebar/weather.py (revision 11576) +++ src/plugins/idlebar/weather.py (working copy) @@ -75,11 +75,11 @@ if pr.getTemperatureCelsius(): if self.tempunits == 'F': - self.temperature = '%2d' % int(pr.getTemperatureFahrenheit()) + self.temperature = '%2d' % pr.getTemperatureFahrenheit() elif self.tempunits == 'K': - self.temperature = '%3d' % int(pr.getTemperatureCelsius() + 273) + self.temperature = '%3d' % pr.getTemperatureCelsius() + 273 else: - self.temperature = '%2d' % int(pr.getTemperatureCelsius()) + self.temperature = '%2d' % pr.getTemperatureCelsius() else: self.temperature = '?' Index: src/util/pymetar.py =================================================================== --- src/util/pymetar.py (revision 11576) +++ src/util/pymetar.py (working copy) @@ -834,9 +834,9 @@ elif (header == "Temperature"): f,i,c,i=data.split(None,3) - self.Report.tempf=int(f) + self.Report.tempf=float(f) # The string we have split is "(NN C)", hence the slice - self.Report.temp=int(c[1:]) + self.Report.temp=float(c[1:]) # wind dir and speed
------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________ Freevo-users mailing list Freevo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-users