Final thoughts Payday loan Top Advantages of our payday loans

The Worldcup Final Python script

The world cup cricket final is happening again. Though I am not an ardent cricket fan, I do love it  , but not without criticism as usual.

I was thinking about today’s final betwen Sri Lanka and Australia. I vote for Australia as they are more professional in cricket ( I don’t care abt the players behaviour, as I don’t value the sweetness in the player’s behaviour, I just valuate them by their performance on ground , not off the ground).

 As I am in office, I have decided to view the latest scores available in Cricinfo website. But as it is not so easy to open and view the website regularly, I have decided to write a Python script to show the latest scores on the Screen (OSD :-0  On screen Display).

  First I have installed the XOSD fromhttp://sourceforge.net/projects/libxosd. Then I have installed the pyosd using the rpm 

  pyosd-0.2.6-1asp.i386.rpm  . To solve the issues in my Redhat Enterprise Linux 4,  I have copy the usr/lib/python2.2/site-package

s/pyosd to /usr/lib/python2.3/site-packages/pyosd  and nd change the default font  of  pyosd library to -adobe-helvetica-bold-r-normal

-*-24-*-*-*-*-*-iso8859-1 as the default font failed to start the pyosd module.
 
Here goes the scripts which reads the latest scores rss from cricinfo.com and displays it on the  screen. It uses the  sax (Simple API for XML) for parsing the xml. Now I can work and watch the scores on the screen simultaneously !!! .
 
 #!/usr/bin/env python
#
# Started on 26, Apr 2007 by Maxin B. John <maxinbjohn@gmail.com>
# This file is licensed under the GPL.
#
#importing the Pyosd and xml parser

import pyosd
from xml.sax import handler, make_parser
import sys, string , time

class SaxDocumentHandler(handler.ContentHandler):

def __init__(self, outfile):
self.outfile = outfile
self.level = 0
self.xmlcontent=”"
self.pubDate=”"
self.titles = “”
self.description=”"
self.displayer= pyosd.osd()

def startDocument(self):
pass

def endDocument(self):
self.displayer.set_colour(“red”)
self.displayer.set_timeout(5)
self.displayer.set_pos(1)
self.displayer.set_shadow_offset(2)
self.displayer.display( self.description )

def startElement(self, name, attrs):
self.level += 1
self.xmlcontent=name

def endElement(self, name):
pass

def characters(self, chrs):
if self.xmlcontent == ‘pubDate’:
self.pubDate+= chrs
if self.xmlcontent == ‘title’:
self.titles+=chrs
if self.xmlcontent == ‘description’:
self.description+=chrs

def xmlparse(inFileName):
outFile = sys.stdout
# Create an instance of the Handler.
handler = SaxDocumentHandler(outFile)
# Create an instance of the parser.
parser = make_parser()
# Set the content handler.
parser.setContentHandler(handler)
# Parse the file
parser.parse(inFileName)
# sleeping for 5 seconds to prevent a sudden exit
time.sleep(5)

def main():
args = sys.argv[1:]
#if len(args) != 1:
#    print ‘usage: python cricketonscreen.py  http://www.cricinfo.com/rss/livescores.xml’
#    sys.exit(-1)
# Here we are depending on cricinfo for the latest scores
xmlparse(“http://www.cricinfo.com/rss/livescores.xml”)

#Finally triger the events

if __name__ == ‘__main__’:
while 1:
main()
time.sleep(5)

 
Just see the output..  It just makes me weep .. out of happiness. Cry
 
 

 

 

Well, it’s because the match has’nt started yet. When the match starts, I will get the live scores Cool

Readmore