""" Python module for use in the SoCal Linux Expo exhibit. project builtin functions. """ from PsychePostProcessor import PsychePostProcessor import sys, time, string class PsycheXmms( PsychePostProcessor ): def __init__( self, arg ): self.infopipe() self.set_result('foo') #self.set_result(self.get_xmms_debug()) def infopipe( self ): self.infopipe = {} try: input = open( '/tmp/xmms-info', 'r').readlines() except IOError: sys.stderr.write( self.nofile ) #for i in range( len(input) ): # key, command = input[i].split(':',1) # self.infopipe[key] = command.strip('\n') def get_track( self ): track = self.infopipe["Title"] return "the current track is %s" % track def get_elapsed( self ): elapsed = self.infopipe["Time"] min, sec = elapsed.split(':') return "the elapsed time is %s minutes %s seconds" % ( min, sec ) def get_length( self ): length = self.infopipe["Position"] min, sec = length.split(':') return "the total track running time is %s minutes %s seconds" % ( min, sec ) def get_raw( self ): print 'Raw:' for key in self.infopipe.keys(): return key, self.infopipe[key] def get_xmms_debug( self ): return string.join( [self.get_track(), self.get_elapsed(), self.get_length()] ) nofile =\ """The file /tmp/xmms-info does not exist. Please ensure that xmms-info is installed and enabled within xmms. Additionally, xmms must be running.""" ################################################################################ if __name__ == '__main__': px = PsycheXmms() print px.get_result()