Wednesday, December 26, 2007

Friday, December 07, 2007

RSS feed reader 3rd Update

Added toaster-pop-up like notification for updates . Clicking the Pop-up will open the corresponding blog entry in the browser.






from sgmllib import SGMLParser
import feedparser
from threading import Thread
from time import mktime, sleep
from re import sub
import pygtk
pygtk.require("2.0")
import gtk

class ParseDoc(SGMLParser):
def get_vals(self):
return self.datalist
def parse(self, data):
self.feed(data)
self.close()
def __init__(self, verbose=0):
SGMLParser.__init__(self, verbose=0)
self.datalist = []
def start_outline(self, attributes):
attrdict = {}
for name, value in attributes:
attrdict[name]=value
self.datalist.append(attrdict)


class FetchFeed(Thread):
def __init__(self, xmlurl):
Thread.__init__(self)
self.xmlurl = xmlurl
self.feedresult = None

def run(self):
d = feedparser.parse(self.xmlurl)
if d.feed.has_key('title'):
self.feedresult = d
def strip_html(text):
def fixup(m):
text = m.group(0)
if text[:1] == "<":
return ""
if text[:2] == "&#":
try:
if text[:3] == "&#x":
return unichr(int(text[3:-1], 16))
else:
return unichr(int(text[2:-1]))
except ValueError:
pass
elif text[:1] == "&":
import htmlentitydefs
entity = htmlentitydefs.entitydefs.get(text[1:-1])
if entity:
if entity[:2] == "&#":
try:
return unichr(int(entity[2:-1]))
except ValueError:
pass
else:
return unicode(entity, "iso-8859-1")
return text
return sub("(?s)<[^>]*>|&#?\w+;", fixup, text)


class ParseBlogs(ParseDoc):

def __init__(self, opmldoc = None):
ParseDoc.__init__(self, verbose=0)
self.lastenty = None
if opmldoc:
fileobj = open(opmldoc);
filedata = fileobj.read()
fileobj.close()
ParseDoc.parse(self, filedata)
self.blogsdata = ParseDoc.get_vals(self)
del self.blogsdata[0]
self.opmldocflag = 1
self.resultlimit = 3

else:
self.blogsdata = ['http://mvblogs.org/mvblogs.xml']
self.opmldocflag = 0
self.resultlimit = None
self.feedresults = []

self.threadlist = []
self.lastparsetime = None

def getfeeds(self, min=0, max=1):

for i in self.blogsdata[min:max]:

if self.opmldocflag:
t = FetchFeed(i['xmlurl'])
else:
t = FetchFeed(self.blogsdata[0])
t.start()
self.threadlist.append(t)

for tl in self.threadlist:
tl.join()
self.getfeed(tl)
self.threadlist = []

def getfeed(self, tl):
results = []
if tl.feedresult:
tlfeed = tl.feedresult.feed
tlresult = tl.feedresult.entries

results.append(tlfeed)
results.append(tlresult)
self.feedresults.append(results)


def printfeeds(self, onlyupdates = 'false'):
print "printing"
for i in self.feedresults:#for each feed

#if limit not set fetch all entries
if not self.resultlimit:self.resultlimit = len(i[1])

for j in range(self.resultlimit):#for each entry

#if onlyupdates then ignore old entries
if onlyupdates == "true" and self.lastparsetime:
if mktime(i[1][j].updated_parsed) <= mktime(self.lastparsetime):
continue

if self.opmldocflag:
print i[0]['author']
print i[0]['title']

print i[1][j].date
print i[1][j].title
print i[1][j].link
print strip_html(i[1][j].description)
print "#"*100
#for updates display popup
if onlyupdates =="true" and self.lastparsetime:
toasterpop = Popup(i[1][j].title, i[1][j].link)

self.lastparsetime = self.feedresults[0][1][0].updated_parsed
self.feedresults = []

class Popup:
def clicky(self, widget, link=None):
os.system("firefox "+link)
gtk.main_quit()

def delete_event(self, widget, event, data=None):
return False

def destroy(self, widget, data=None):
gtk.main_quit()

def __init__(self,message = "Hello World", link="http://vishah.blogspot.com"):
self.toaster = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.toaster.set_title("New!!")
self.toaster.connect("destroy", self.destroy)
self.toaster.connect("delete_event", self.delete_event)
self.button = gtk.Button(message)
self.button.connect("clicked",self.clicky, link)
self.toaster.add(self.button)
self.toaster.set_gravity(gtk.gdk.GRAVITY_SOUTH_EAST)
self.toaster.resize(150,150)
width, height = self.toaster.get_size()
self.toaster.move(gtk.gdk.screen_width() - width, gtk.gdk.screen_height() - height)
self.toaster.show_all()
self.main()


def main(self):
gtk.main()

#parseobj = ParseBlogs('mvblogs-export.xml')
#parseobj.getfeeds(0,3)
parseobj = ParseBlogs()
while(1):
parseobj.getfeeds()
parseobj.printfeeds('true')
sleep(20)



Sunday, December 02, 2007

Invitation for Linux and free software enthusiasts

http://www.facebook.com/group.php?gid=2433611028

Join this facebook group for discussion and support.

Why Free/Open Source Software??
http://www.gnu.org/philosophy/

Free software is a matter of freedom: people should be free to use software in all the ways that are socially useful. Software differs from material objects—such as chairs, sandwiches, and gasoline—in that it can be copied and changed much more easily. These possibilities make software as useful as it is; we believe software users should be able to make use of them.

  • The freedom to run the program, for any purpose (freedom 0).
  • The freedom to study how the program works, and adapt it to your needs (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to improve the program, and release your improvements to the public, so that the whole community benefits (freedom 3). Access to the source code is a precondition for this.

Saturday, December 01, 2007

openSUSE YeaaaHH

Installed the latest openSUSE version 10.3 today.In my opinion this is the distro which has the best implementation of KDE.

5:40 At the moment installing NVIDIA drivers
http://en.opensuse.org/NVIDIA
As you can see in the NVIDIA page, it's very easy to install software ..Instead of downloading the RPMs and manually installing, you can install any software in their catalog by 1-Click technology.

5:52 installing Compiz Fusion
http://en.opensuse.org/Compiz-Fusion
This is for the eye candy..Minimizing effects, fire on the screen.ripple effects etc. Some plugins increases usability also.

6:10 Installing dhivehi fonts.There is a GUI way of downloading the fonts manually and installing it..But using a script or a set of commands is also an option.
su
mkdir fonts
cd fonts
mkdir /usr/share/fonts/truetype/Dhivehi
wget http://www.haveeru.com.mv/fonts.zip
mkdir dhivehifonts
unzip -d dhivehifonts fonts.zip
rm fonts.zip
wget -P dhivehifonts "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20GroupX%20Avas.otf.ttf" "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20Iyyu%20Normal.otf.ttf" "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20MAG%20Round.otf.ttf" "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20MAG%20Round%20XBold.otf.ttf" "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20Sehga%20Old.otf.ttf" "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20Iyyu%20Nala.otf.ttf" "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20Lady%20Luck.otf.ttf" "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20MAG%20Round%20Hollow.otf.ttf" "http://www.mcst.gov.mv/Downloads/New/Divehi%20xp%20fonts/Mv%20Sehga%20FB.otf.ttf" "http://www.mcst.gov.mv/Downloads/Fonts/Mv%20Galan.ttf"
mv dhivehifonts/*.TTF dhivehifonts/*.ttf /usr/share/fonts/truetype/Dhivehi/
fc-cache -f -v

Configuring Compiz
Enable Expo


Enable Cube Gears


Suse kickoff menu
has been ported to KDE 4.



1:46 Multimedia codecs
( after going out for a little birthday celebration :D )
http://opensuse-community.org/Multimedia

openSUSE.org