Update of /cvsroot/freevo/freevo/WIP/Ruelle In directory sc8-pr-cvs1:/tmp/cvs-serv17353
Modified Files: tvtime.py Log Message: adding xmltv support for tvtime Index: tvtime.py =================================================================== RCS file: /cvsroot/freevo/freevo/WIP/Ruelle/tvtime.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tvtime.py 30 Sep 2003 14:46:50 -0000 1.9 --- tvtime.py 2 Oct 2003 00:31:54 -0000 1.10 *************** *** 10,15 **** # ----------------------------------------------------------------------- # $Log$ ! # Revision 1.9 2003/09/30 14:46:50 mikeruelle ! # commit for now. ideally we need to send geometry # # Revision 1.17 2003/09/03 17:54:38 dischi --- 10,15 ---- # ----------------------------------------------------------------------- # $Log$ ! # Revision 1.10 2003/10/02 00:31:54 mikeruelle ! # adding xmltv support for tvtime # # Revision 1.17 2003/09/03 17:54:38 dischi *************** *** 56,59 **** --- 56,60 ---- import cgi import re + import popen2 import util # Various utilities *************** *** 80,84 **** # get config locations and mod times so we can check if we need ! # to regen the stationlist.xml file (because they changed) self.mylocalconf = self.findLocalConf() self.myfconfig = os.environ['FREEVO_CONFIG'] --- 81,85 ---- # get config locations and mod times so we can check if we need ! # to regen xml config files (because they changed) self.mylocalconf = self.findLocalConf() self.myfconfig = os.environ['FREEVO_CONFIG'] *************** *** 87,96 **** self.myfconfig_t = os.path.getmtime(self.myfconfig) ! #check and create the stationlist.xml if it doesn't exist ! self.createStationListXML() # create the tvtime object and register it plugin.register(TVTime(), plugin.TV) def findLocalConf(self): cfgfilepath = [ '.', os.path.expanduser('~/.freevo'), '/etc/freevo' ] --- 88,122 ---- self.myfconfig_t = os.path.getmtime(self.myfconfig) ! self.xmltv_supported = self.isXmltvSupported() ! ! #check/create the stationlist.xml and tvtime.xml ! self.createTVTimeConfig() # create the tvtime object and register it plugin.register(TVTime(), plugin.TV) + def isXmltvSupported(self): + helpcmd = '%s --help' % config.TVTIME_CMD + has_xmltv=False + print helpcmd + child = popen2.Popen3( helpcmd, 1, 100) + data = child.childerr.readline() # Just need the first line + print data + if data: + data = re.search( "^tvtime: Running tvtime (?P<major>\d+).(?P<minor>\d+).(?P<version>\d+).", data ) + if data: + print "major is: %s" % data.group( "major" ) + print "minor is: %s" % data.group( "minor" ) + print "version is: %s" % data.group( "version" ) + major = int(data.group( "major" )) + minor = int(data.group( "minor" )) + ver = int(data.group( "version" )) + if major > 0: + has_xmltv=True + elif major == 0 and minor == 9 and ver >= 10: + has_xmltv=True + child.wait() + return has_xmltv + def findLocalConf(self): cfgfilepath = [ '.', os.path.expanduser('~/.freevo'), '/etc/freevo' ] *************** *** 102,121 **** return mylocalconf ! # BUG: we should really merge when we find an existing stationlist.xml ! def createStationListXML(self): tvtimedir = os.path.join(os.environ['HOME'], '.tvtime') ! if (os.path.isfile(os.path.join(tvtimedir, 'stationlist.xml'))): ! print "found stationlist.xml" ! if self.needNewStationList(): ! self.writeStationListXML() ! self.writeMtimeCache() ! else: ! print "not found stationlist.xml" ! if not os.path.isdir(tvtimedir): ! os.mkdir(tvtimedir) self.writeStationListXML() self.writeMtimeCache() ! def needNewStationList(self): if not os.path.isfile(self.tvtimecache): print 'no cache file' --- 128,149 ---- return mylocalconf ! # BUG: we should really merge when we find an existing xml config ! def createTVTimeConfig(self): tvtimedir = os.path.join(os.environ['HOME'], '.tvtime') ! if not os.path.isdir(tvtimedir): ! os.mkdir(tvtimedir) ! if self.needNewConfigs(): self.writeStationListXML() + self.writeTvtimeXML() self.writeMtimeCache() ! def needNewConfigs(self): ! tvtimedir = os.path.join(os.environ['HOME'], '.tvtime') ! if not os.path.isfile(os.path.join(tvtimedir, 'stationlist.xml')): ! return 1 ! ! if not os.path.isfile(os.path.join(tvtimedir, 'tvtime.xml')): ! return 1 ! if not os.path.isfile(self.tvtimecache): print 'no cache file' *************** *** 158,161 **** --- 186,199 ---- fp.close() + def writeTvtimeXML(self): + configcmd = "tvtime-configure" + cf_norm, cf_input, cf_clist, cf_device = config.TV_SETTINGS.split() + s_norm = cf_norm.upper() + if self.xmltv_supported: + daoptions = ' -d %s -n %s -t %s' % (cf_device, s_norm, config.XMLTV_FILE) + else: + daoptions = ' -d %s -n %s' % (cf_device, s_norm) + os.system(configcmd+daoptions) + def writeStationListXML(self): print "writing new stationlist.xml" *************** *** 180,184 **** mychan = mychan / 1000.0 mychan = "%.2fMHz" % mychan ! fp.write(' <station name="%s" active="1" position="%s" band="%s" channel="%s"/>\n' % (cgi.escape(m[1]),c,myband,mychan)) c = c + 1 --- 218,225 ---- mychan = mychan / 1000.0 mychan = "%.2fMHz" % mychan ! if self.xmltv_supported: ! fp.write(' <station name="%s" xmltvid="%s" active="1" position="%s" band="%s" channel="%s"/>\n' % (cgi.escape(m[1]), m[0], c, myband, mychan)) ! else: ! fp.write(' <station name="%s" active="1" position="%s" band="%s" channel="%s"/>\n' % (cgi.escape(m[1]),c,myband,mychan)) c = c + 1 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Freevo-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freevo-cvslog