Author: duncan
Date: Mon Mar 17 05:09:56 2008
New Revision: 10539

Log:
[ 1911578 ] TVGuide Fonts are all blurred
Fix applied, problem caused by the channel's programs all pointing to the same 
object
Removed the verbose stuff as this is handled by _debug_


Modified:
   branches/rel-1/freevo/src/config.py
   branches/rel-1/freevo/src/helpers/cache.py
   branches/rel-1/freevo/src/tv/epg_types.py
   branches/rel-1/freevo/src/tv/epg_xmltv.py

Modified: branches/rel-1/freevo/src/config.py
==============================================================================
--- branches/rel-1/freevo/src/config.py (original)
+++ branches/rel-1/freevo/src/config.py Mon Mar 17 05:09:56 2008
@@ -911,10 +911,8 @@
         import pickle
 
     file = XMLTV_FILE
-    path = FREEVO_CACHEDIR
-    pfile = 'xmltv_channels.pickle'
 
-    pname = os.path.join(path, pfile)
+    pname = os.path.join(FREEVO_CACHEDIR, 'xmltv_channels.pickle')
 
     if not os.path.isfile(file):
         if not HELPER:

Modified: branches/rel-1/freevo/src/helpers/cache.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/cache.py  (original)
+++ branches/rel-1/freevo/src/helpers/cache.py  Mon Mar 17 05:09:56 2008
@@ -443,7 +443,7 @@
     sys.__stdout__.flush()
 
     import tv.epg_xmltv
-    tv.epg_xmltv.get_guide(verbose=False)
+    tv.epg_xmltv.get_guide()
     print 'done'
 
 def print_help():

Modified: branches/rel-1/freevo/src/tv/epg_types.py
==============================================================================
--- branches/rel-1/freevo/src/tv/epg_types.py   (original)
+++ branches/rel-1/freevo/src/tv/epg_types.py   Mon Mar 17 05:09:56 2008
@@ -42,24 +42,6 @@
     """
     Holds information about a TV programme
     """
-    channel_id = None
-    title      = None
-    desc       = None
-    sub_title  = None
-    start      = None
-    pdc_start  = None
-    stop       = None
-    ratings    = None
-    advisories = None
-    categories = None
-    date       = None
-    # this information is added by the recordserver
-    scheduled  = None
-    overlap    = None
-    previouslyRecorded = None
-    allowDuplicates = None
-    onlyNew = None
-
     def __init__(self, channel_id='', start=0, pdc_start=0, stop=0, title='', 
sub_title='', desc='', categories=[], ratings={}):
         _debug_('TvProgram.__init__(channel_id=%r, start=%r, stop=%r, 
title=%r)' % (channel_id, start, stop, title), 1)
         self.title      = title
@@ -74,8 +56,7 @@
         self.categories = categories
         self.date       = None
 
-        # Due to problems with Twisted's marmalade this should not be changed
-        # to a boolean type.
+        # this information is added by the recordserver
         self.scheduled  = 0
         self.overlap    = 0
         self.previouslyRecorded = 0
@@ -179,22 +160,22 @@
     """
     Holds information about a TV channel
     """
-    id = '' 
-    displayname = '' 
-    tunerid = '' 
-    logo = ''
-    times = None 
-    programs = None 
+    #id = ''
+    #displayname = ''
+    #tunerid = ''
+    #logo = ''
+    #times = None
+    #programs = None
 
-    def __init__(self, id, displayname, tunerid, logo='', times=[], 
programs=[]):
+    def __init__(self, id, displayname, tunerid, logo='', times=[]):
         """ Copy the programs that are inside the indicated time bracket """
-        _debug_('TvChannel.__init__(id=%r, displayname=%r, tunerid=%r, 
logo=%r, times=%r, programs=%r)' % (id, displayname, tunerid, logo, times, 
programs), 1)
+        _debug_('TvChannel.__init__(id=%r, displayname=%r, tunerid=%r, 
logo=%r, times=%r)' % (id, displayname, tunerid, logo, times), 1)
         self.id = id
         self.displayname = displayname
         self.tunerid = tunerid
         self.logo = logo
         self.times = times
-        self.programs = programs
+        self.programs = []
 
 
     def set_programs(self, programs):
@@ -229,13 +210,10 @@
 class TvGuide:
     """
     """
-    chan_dict = None
-    chan_list = None
-    timestamp = 0.0
-
     def __init__(self):
         _debug_('TvGuide.__init__()', 1)
         # These two types map to the same channel objects
+        timestamp = 0.0
         self.chan_dict = {}   # Channels mapped using the id
         self.chan_list = []   # Channels, ordered
         self.EPG_VERSION = EPG_VERSION
@@ -275,7 +253,7 @@
         """
         Get all programs that occur at least partially between the start and 
stop
         timeframe.
-        
+
         @param start: is 0, get all programs from the start.
         @param stop: is 2147483647, get all programs until the end.
         @param channel_id: can be used to select a channel id, all channels 
are returned otherwise.
@@ -296,7 +274,7 @@
             if channel_id and chan.id != channel_id:
                 continue
 
-            c = TvChannel(chan.id, chan.displayname, chan.tunerid, chan.logo, 
chan.times, programs=[])
+            c = TvChannel(chan.id, chan.displayname, chan.tunerid, chan.logo, 
chan.times)
             # Copy the programs that are inside the indicated time bracket
             f = lambda p, a=start, b=stop: not (p.start > b or p.stop < a)
             c.set_programs(filter(f, chan.programs))

Modified: branches/rel-1/freevo/src/tv/epg_xmltv.py
==============================================================================
--- branches/rel-1/freevo/src/tv/epg_xmltv.py   (original)
+++ branches/rel-1/freevo/src/tv/epg_xmltv.py   Mon Mar 17 05:09:56 2008
@@ -62,7 +62,7 @@
 cached_guide = None
 
 
-def get_guide(popup=None, verbose=True, XMLTV_FILE=None):
+def get_guide(popup=None, XMLTV_FILE=None):
     """
     Get a TV guide from memory cache, file cache or raw XMLTV file.
     Tries to return at least the channels from the config file if there
@@ -83,10 +83,8 @@
 
         got_cached_guide = False
         if (os.path.isfile(XMLTV_FILE) and
-            os.path.isfile(pname) and (os.path.getmtime(pname) >
-                                       os.path.getmtime(XMLTV_FILE))):
-            if verbose:
-                _debug_('XMLTV, reading cached file (%s)' % pname)
+            os.path.isfile(pname) and (os.path.getmtime(pname) > 
os.path.getmtime(XMLTV_FILE))):
+            _debug_('XMLTV, reading cached file (%s)' % pname)
 
             if popup:
                 popup.show()
@@ -97,24 +95,19 @@
             try:
                 epg_ver = cached_guide.EPG_VERSION
             except AttributeError:
-                if verbose:
-                    _debug_('EPG does not have a version number, must be 
reloaded')
-                    print dir(cached_guide)
+                _debug_('EPG does not have a version number, must be reloaded')
 
             if epg_ver != EPG_VERSION:
-                if verbose:
-                    _debug_('EPG version missmatch, must be reloaded')
+                _debug_('EPG version missmatch, must be reloaded')
 
             elif cached_guide.timestamp != os.path.getmtime(XMLTV_FILE):
                 # Hmmm, weird, there is a pickled file newer than the TV.xml
                 # file, but the timestamp in it does not match the TV.xml
                 # timestamp. We need to reload!
-                if verbose:
-                    _debug_('EPG: Pickled file timestamp mismatch, reloading!')
+                _debug_('EPG: Pickled file timestamp mismatch, reloading!')
 
             else:
-                if verbose:
-                    _debug_('XMLTV, got cached guide (version %s).' % epg_ver)
+                _debug_('XMLTV, got cached guide (version %s).' % epg_ver)
                 got_cached_guide = True
 
         if not got_cached_guide:
@@ -123,10 +116,9 @@
             if popup:
                 popup.show()
 
-            if verbose:
-                _debug_('XMLTV, trying to read raw file (%s)' % XMLTV_FILE)
+            _debug_('XMLTV, trying to read raw file (%s)' % XMLTV_FILE)
             try:
-                cached_guide = load_guide(verbose, XMLTV_FILE)
+                cached_guide = load_guide(XMLTV_FILE)
             except:
                 # Don't violently crash on a incomplete or empty TV.xml please.
                 cached_guide = None
@@ -138,6 +130,7 @@
                 # Replace config.XMLTV_FILE before we save the pickle in order
                 # to avoid timestamp confision.
                 if XMLTV_FILE != config.XMLTV_FILE:
+                    _debug_('copying %r -> %r' % (XMLTV_FILE, 
config.XMLTV_FILE), DINFO)
                     shutil.copyfile(XMLTV_FILE, config.XMLTV_FILE)
                     os.unlink(XMLTV_FILE)
                     cached_guide.timestamp = 
os.path.getmtime(config.XMLTV_FILE)
@@ -155,7 +148,7 @@
     return cached_guide
 
 
-def load_guide(verbose=True, XMLTV_FILE=None):
+def load_guide(XMLTV_FILE=None):
     """
     Load a guide from the raw XMLTV file using the xmltv.py support lib.
     Returns a TvGuide or None if an error occurred
@@ -177,8 +170,7 @@
     # Add the channels that are in the config list, or all if the
     # list is empty
     if config.TV_CHANNELS:
-        if verbose:
-            _debug_('epg_xmltv.py: Only adding channels in list')
+        _debug_('Only adding channels in TV_CHANNELS to TvGuide')
 
         for data in config.TV_CHANNELS:
             (id, displayname, tunerid) = data[:3]
@@ -193,8 +185,8 @@
 
 
     else: # Add all channels in the XMLTV file
-        if verbose:
-            _debug_('epg_xmltv.py: Adding all channels')
+        _debug_('Adding all channels to TvGuide')
+
         xmltv_channels = None
         if gotfile:
             # Don't read the channel info unless we have to, takes a long time!
@@ -208,24 +200,22 @@
             id = chan['id'].encode(config.LOCALE, 'ignore')
             if ' ' in id:
                 # Assume the format is "TUNERID CHANNELNAME"
-                displayname = id.split()[1]   # XXX Educated guess
                 tunerid = id.split()[0]       # XXX Educated guess
+                displayname = id.split()[1]   # XXX Educated guess
             else:
-                displayname = chan['display-name'][0][0]
-                if ' ' in displayname:
-                    displayname = displayname.split()[1]
-                    tunerid = displayname.split()[0]
+                display_name = chan['display-name'][0][0]
+                if ' ' in display_name:
+                    tunerid = display_name.split()[0]
+                    displayname = display_name.split()[1]
                 else:
-                    displayname = displayname
-                    tunerid = _('REPLACE WITH TUNERID FOR %s') % displayname
-            c = TvChannel(id, displayname, tunerid)
+                    tunerid = _('REPLACE WITH TUNERID FOR %s') % display_name
 
+            c = TvChannel(id, displayname, tunerid)
             guide.add_channel(c)
 
     xmltv_programs = None
     if gotfile:
-        if verbose:
-            _debug_('reading \"%s\" xmltv data' % XMLTV_FILE)
+        _debug_('reading \"%s\" xmltv data' % XMLTV_FILE)
         f = util.gzopen(XMLTV_FILE)
         xmltv_programs = xmltv.read_programmes(f)
         f.close()
@@ -234,13 +224,11 @@
     if not xmltv_programs:
         return guide    # Return the guide, it has the channels at least...
 
-
     needed_ids = []
     for chan in guide.chan_dict:
         needed_ids.append(chan)
 
-    if verbose:
-        _debug_('creating guide for %s' % needed_ids)
+    _debug_('creating guide for %s' % needed_ids)
 
     for p in xmltv_programs:
         if not p['channel'] in needed_ids:
@@ -367,9 +355,12 @@
     xmltv_file = config.XMLTV_FILE
     if len(sys.argv) > 1:
         xmltv_file = sys.argv[1]
+    print '%r' % xmltv_file
     import pdb
     pdb.set_trace()
-    guide = load_guide(True, xmltv_file)
+    guide = load_guide(xmltv_file)
     print '%r' % (guide,)
-    print '%r' % (dir(guide),)
-    print '%r' % (guide.__dict__,)
+    for channel in guide.chan_list:
+        print '  %r' % channel
+        for program in channel.programs:
+            print '    %r' % program

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to