Author: rshortt
Date: Sun Mar 12 18:14:38 2006
New Revision: 1280

Modified:
   trunk/WIP/epg2/src/client.py
   trunk/WIP/epg2/src/server.py

Log:
Avoid conflicting tuner_ids.  The conflict can be resolved by the application 
using the epg.


Modified: trunk/WIP/epg2/src/client.py
==============================================================================
--- trunk/WIP/epg2/src/client.py        (original)
+++ trunk/WIP/epg2/src/client.py        Sun Mar 12 18:14:38 2006
@@ -1,4 +1,6 @@
 import libxml2, sys, time, os, weakref, cPickle
+import logging
+
 from kaa import ipc, db
 from kaa.notifier import Signal
 from server import *
@@ -7,6 +9,8 @@
 
 __all__ = ['GuideClient']
 
+log = logging.getLogger()
+
 
 class GuideClient(object):
     def __init__(self, server_or_socket, auth_secret = None):
@@ -44,7 +48,13 @@
             self._channels_by_name[short_name] = chan
             self._channels_by_db_id[db_id] = chan
             for t in tuner_id:
-                self._channels_by_tuner_id[t] = chan
+                if self._channels_by_tuner_id.has_key(t):
+                    log.warning('loading channel %s with tuner_id %s '+\
+                                'allready claimed by channel %s', 
+                                chan.short_name, t, 
+                                self._channels_by_tuner_id[t].short_name)
+                else:
+                    self._channels_by_tuner_id[t] = chan
             self._channels_list.append(chan)
 
         self._max_program_length = self._server.get_max_program_length()

Modified: trunk/WIP/epg2/src/server.py
==============================================================================
--- trunk/WIP/epg2/src/server.py        (original)
+++ trunk/WIP/epg2/src/server.py        Sun Mar 12 18:14:38 2006
@@ -56,6 +56,7 @@
         }
 
         self._clients = []
+        self._tuner_ids = []
         self._db = db
         self._load()
         
@@ -202,11 +203,18 @@
         c2 = self._db.query(type = "channel", short_name = short_name)
         if len(c2):
             c2 = c2[0]
-            log.debug('c2: %s', c2)
+            #log.debug('c2: %s', c2)
 
             for t in tuner_id:
                 if t not in c2["tuner_id"]:
-                    c2["tuner_id"].append(t)
+                    if t not in self._tuner_ids:
+                        # only add this id if it's not already there and not
+                        # claimed by another channel
+                        c2["tuner_id"].append(t)
+                        self._tuner_ids.append(t)
+                    else:
+                        log.warning('not adding tuner_id %s for channel %s - 
'+\
+                            'it is claimed by another channel', t, short_name)
 
             # TODO: if everything is the same do not update
             self._db.update_object(("channel", c2["id"]),
@@ -214,6 +222,14 @@
                                    long_name = long_name)
             return c2["id"]
 
+        for t in tuner_id:
+            if t in self._tuner_ids:
+                log.warning('not adding tuner_id %s for channel %s - it is '+\
+                            'claimed by another channel', t, short_name)
+                tuner_id.remove(t)
+            else:
+                self._tuner_ids.append(t)
+
         o = self._db.add_object("channel", 
                                 tuner_id = tuner_id,
                                 short_name = short_name,
@@ -233,7 +249,7 @@
             # we have a program at this time
             p2 = p2[0]
 
-            log.debug('updating program: %s', p2["title"])
+            #log.debug('updating program: %s', p2["title"])
             # TODO: if everything is the same do not update
             self._db.update_object(("program", p2["id"]),
                                    start = start,
@@ -245,7 +261,7 @@
         # TODO: check title, see if it is a different program.  Also check
         #       if the program is the same but shifted times a bit
         else:
-            log.debug('adding program: %s', title)
+            #log.debug('adding program: %s', title)
             o = self._db.add_object("program", 
                                     parent = ("channel", channel_db_id),
                                     start = start,


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to