Image 01
profile-image

gosom

Giorgos Komninos
plasma_pyweather

Plasma 4 Extensions by rangalo 53 comments

The problem lies in line 32:
sock = urllib.urlopen(strUrl)

you need a timeout there so change line 10

old: import sys, urllib, codecs
new: import sys, urllib, urllib2, codecs

and line 32
old: sock = urllib.urlopen(strUrl)
new : sock = urllib2.urlopen(strUrl, timeout=1)

so it justs waits 1 second and if no connection
throws exception and the load continues - Mar 18 2012
plasma_pyweather

Plasma 4 Extensions by rangalo 53 comments

I installed pyweather while connected to the internet and it worked fine.

When I rebooted kde could not load.

I booted to failsafe and deleted:
rm ~/.kde4/config/plas*

and then i managed to login normal.

Then I tried to install pyweather without being connected to the internet and desktop frozen.

- Mar 18 2012
Simple CPU Sensor

Plasma 4 Extensions by alexoleshkevich 38 comments

Thanks for the widget!

In main.py in the function updateLabel you use:
sensor = commands.getoutput("sensors | grep temp1");

In case sensors are not installed variable sensor would be a string like "command not found",
so when you try to :
t = int(float(sensor)) would raise a ValueError exception.

The problem is that a user in the widget justs sees script initialization failed and has no clue that sensors are missing.

So i suggest to do:
try:
t = int(float(sensor))
except ValueError:
error_msg = 'Unable to get cpu temperature using sensors command, is sensors installed?'

and in the end where you check

to_show = t
if (t > self.overheat_level):
self.color = self.overheat_color
elif ( t == -1):
self.color = self.overheat_color
to_show = error_msg

self.label.setText('<font color="' + self.color + '"><b>' + str(to_show) + '&deg; C</b></font>')

So the widget tells the user what is the error.

Probably you can do it with better code but just keep the idea :) - Mar 18 2012