Author: tack
Date: Sun Apr 15 19:47:07 2007
New Revision: 2625

Modified:
   trunk/epg/src/__init__.py
   trunk/epg/src/client.py
   trunk/epg/src/server.py

Log:
Use default 'epg' as socket identifier; implicitly connect to server when using
module convenience functions like beacon does.


Modified: trunk/epg/src/__init__.py
==============================================================================
--- trunk/epg/src/__init__.py   (original)
+++ trunk/epg/src/__init__.py   Sun Apr 15 19:47:07 2007
@@ -52,13 +52,12 @@
 # connected client object
 guide = Client()
 
-def connect(address, auth_secret=''):
+def connect(address = 'epg', auth_secret = ''):
     """
-    Connect to the epg server with the given address.
+    Connect to the epg server with the given address and auth secret.
     """
-    if not guide.status == DISCONNECTED:
+    if guide.status != DISCONNECTED:
         log.warning('connecting to a new epg database')
-        guide.connect(address, auth_secret)
     guide.connect(address, auth_secret)
     return guide
 
@@ -67,18 +66,18 @@
     """
     Return a list of all channels.
     """
-    if not guide.status == DISCONNECTED:
-        return guide.get_channels(sort)
-    return []
+    if guide.status == DISCONNECTED:
+        connect()
+    return guide.get_channels(sort)
 
 
 def get_channel(name):
     """
     Return the channel with the given name.
     """
-    if not guide.status == DISCONNECTED:
-        return guide.get_channel(name)
-    return []
+    if guide.status == DISCONNECTED:
+        connect()
+    return guide.get_channel(name)
 
 
 def search(channel=None, time=None, block=False, **kwargs):
@@ -88,6 +87,12 @@
     True the function to block using kaa.notifier.step() until the result
     arrived from the server.
     """
+    if guide.status == DISCONNECTED:
+        connect()
+        if block:
+            while guide.status == CONNECTING:
+                kaa.notifier.step()
+
     if block:
         wait = guide.search(channel, time, **kwargs)
         while not wait.is_finished:

Modified: trunk/epg/src/client.py
==============================================================================
--- trunk/epg/src/client.py     (original)
+++ trunk/epg/src/client.py     Sun Apr 15 19:47:07 2007
@@ -91,7 +91,7 @@
 
 
 
-    def connect(self, server_or_socket, auth_secret = ''):
+    def connect(self, server_or_socket = 'epg', auth_secret = ''):
         """
         Connect to EPG server.
         """
@@ -156,8 +156,7 @@
         """
         if self.status == DISCONNECTED:
             # make sure we always return InProgress
-            yield kaa.notifier.YieldContinue
-            yield []
+            raise SystemError('Client is disconnected')
 
         while self.status == CONNECTING:
             yield kaa.notifier.YieldContinue

Modified: trunk/epg/src/server.py
==============================================================================
--- trunk/epg/src/server.py     (original)
+++ trunk/epg/src/server.py     Sun Apr 15 19:47:07 2007
@@ -243,7 +243,7 @@
         """
         Callback when a client disconnects.
         """
-        log.warning('disconnect client %s', client)
+        log.info('Client disconnected: %s', client)
         self._clients.remove(client)
 
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to