Author: dmeyer
Date: Tue Jan 22 14:46:59 2008
New Revision: 3004

Log:
adjust to yield_execution changes

Modified:
   trunk/base/API_CHANGES.txt
   trunk/base/src/notifier/decorators.py
   trunk/base/src/notifier/jobserver.py
   trunk/beacon/setup.py
   trunk/beacon/src/client.py
   trunk/beacon/src/db.py
   trunk/beacon/src/file.py
   trunk/beacon/src/item.py
   trunk/beacon/src/media.py
   trunk/beacon/src/query.py
   trunk/beacon/src/server/crawl.py
   trunk/beacon/src/server/hwmon/client.py
   trunk/beacon/src/server/monitor.py
   trunk/beacon/src/server/parser.py
   trunk/beacon/src/server/server.py
   trunk/epg/src/__init__.py
   trunk/epg/src/client.py
   trunk/epg/src/server.py
   trunk/feedmanager/setup.py
   trunk/feedmanager/src/core.py
   trunk/feedmanager/src/rss.py

Modified: trunk/base/API_CHANGES.txt
==============================================================================
--- trunk/base/API_CHANGES.txt  (original)
+++ trunk/base/API_CHANGES.txt  Tue Jan 22 14:46:59 2008
@@ -34,3 +34,8 @@
 
 7. All exception handlers now take three arguments (instead of one): 
    exception type, exception value, traceback.
+
+8. yield_execution now always returns an InProgress object. This
+   InProgress object may already be finished. Using yield on a
+   finished object will return without waiting. For Python 2.5 the
+   yield also returns the value or can raise an exception.

Modified: trunk/base/src/notifier/decorators.py
==============================================================================
--- trunk/base/src/notifier/decorators.py       (original)
+++ trunk/base/src/notifier/decorators.py       Tue Jan 22 14:46:59 2008
@@ -37,7 +37,6 @@
 # notifier thread imports
 from thread import MainThreadCallback, is_mainthread
 from kaa.weakref import weakref
-from yieldfunc import InProgress
 
 # get logging object
 log = logging.getLogger('notifier')

Modified: trunk/base/src/notifier/jobserver.py
==============================================================================
--- trunk/base/src/notifier/jobserver.py        (original)
+++ trunk/base/src/notifier/jobserver.py        Tue Jan 22 14:46:59 2008
@@ -39,7 +39,6 @@
 
 # kaa notifier imports
 from callback import Signal, Callback
-from async import InProgress
 import thread
 
 # internal list of named threads
@@ -76,8 +75,6 @@
     """
     A callback to run a function in a thread. This class is used by
     execute_in_thread, but it is also possible to use this call directly.
-    The class inherits from InProgress and will call the connected functions
-    on termination or exception.
     """
     def __init__(self, thread_information, func, *args, **kwargs):
         Callback.__init__(self, func, *args, **kwargs)

Modified: trunk/beacon/setup.py
==============================================================================
--- trunk/beacon/setup.py       (original)
+++ trunk/beacon/setup.py       Tue Jan 22 14:46:59 2008
@@ -33,6 +33,11 @@
 # python imports
 import sys
 
+# We require python 2.5 or later, so complain if that isn't satisfied.
+if sys.version.split()[0] < '2.5':
+    print "Python 2.5 or later required."
+    sys.exit(1)
+
 try:
     # kaa base imports
     from kaa.distribution.core import Extension, setup

Modified: trunk/beacon/src/client.py
==============================================================================
--- trunk/beacon/src/client.py  (original)
+++ trunk/beacon/src/client.py  Tue Jan 22 14:46:59 2008
@@ -333,9 +333,10 @@
         # some time until it tries again. That time is too long, it
         # can take up to two seconds.
         yield self.rpc('db.lock')
-        result = self._db.query_media(media)
-        self.rpc('db.unlock')
-        yield result
+        try:
+            yield self._db.query_media(media)
+        finally:
+            self.rpc('db.unlock')
 
 
     def _beacon_parse(self, item):
@@ -367,9 +368,8 @@
             # in the client medialist.add has to lock the db
             # and needs the db.lock rpc which will always result
             # in returning an InProgress object.
-            async = self._db.medialist.add(id, prop)
-            yield async
-            new_media.append(async.get_result())
+            m = yield self._db.medialist.add(id, prop)
+            new_media.append(m)
         self.status = CONNECTED
         self.signals['connect'].emit()
         # reconnect query monitors

Modified: trunk/beacon/src/db.py
==============================================================================
--- trunk/beacon/src/db.py      (original)
+++ trunk/beacon/src/db.py      Tue Jan 22 14:46:59 2008
@@ -158,8 +158,8 @@
     def query(self, **query):
         """
         Main query function. This function will call one of the specific
-        query functions ins this class depending on the query. This function
-        may raise an AsyncProcess exception.
+        query functions in this class depending on the query. This function
+        returns an InProgress.
         """
         qlen = len(query)
         if not 'media' in query:
@@ -173,9 +173,9 @@
         # do query based on type
         if 'filename' in query and qlen == 1:
             fname = os.path.realpath(query['filename'])
-            return self.query_filename(fname)
+            return kaa.yield_execution()(self.query_filename)(fname)
         if 'id' in query and qlen == 1:
-            return self._db_query_id(query['id'])
+            return kaa.yield_execution()(self._db_query_id)(query['id'])
         if 'parent' in query and 'recursive' in query and qlen == 2:
             if not query['parent']._beacon_isdir:
                 raise AttributeError('parent is no directory')
@@ -186,9 +186,9 @@
                     return self._db_query_dir(query['parent'])
             query['parent'] = query['parent']._beacon_id
         if 'attr' in query:
-            return self._db_query_attr(query)
+            return kaa.yield_execution()(self._db_query_attr)(query)
         if 'type' in query and query['type'] == 'media':
-            return self._db.query(**query)
+            return kaa.yield_execution()(self._db.query)(**query)
         return self._db_query_raw(query)
 
 
@@ -238,14 +238,7 @@
         else:
             dirname = parent.filename[:-1]
 
-        listing = parent._beacon_listdir(async=True)
-
-        if isinstance(listing, kaa.InProgress):
-            # oops, something takes more time than we had in mind,
-            yield listing
-            # when we reach this point, we can continue
-            listing = listing()
-
+        listing = parent._beacon_listdir()
         items = []
         if parent._beacon_id:
             items = [ create_by_type(i, parent, isdir=i['type'] == 'dir') \
@@ -357,9 +350,8 @@
                 else:
                     items.append(create_by_type(i, parent))
             if time.time() > timer + 0.1:
-                # we are in async mode and already use too much time.
-                # call yield YieldContinue at this point to continue
-                # later.
+                # we used too much time. Call yield YieldContinue at
+                # this point to continue later.
                 timer = time.time()
                 yield kaa.YieldContinue
 
@@ -453,9 +445,8 @@
 
             counter += 1
             if not counter % 50 and time.time() > timer + 0.05:
-                # we are in async mode and already use too much time.
-                # call yield YieldContinue at this point to continue
-                # later.
+                # We used too much time. Call yield YieldContinue at
+                # this point to continue later.
                 timer = time.time()
                 yield kaa.YieldContinue
 
@@ -465,6 +456,13 @@
         yield result
 
 
+    def query_name_and_parent(self, name, parent):
+        """
+        Return item for name (string) and parent (type, id).
+        """
+        return self._db.query(name=name, parent=parent)[0]
+
+
     def query_filename(self, filename):
         """
         Return item for filename, can't be in overlay. This function will

Modified: trunk/beacon/src/file.py
==============================================================================
--- trunk/beacon/src/file.py    (original)
+++ trunk/beacon/src/file.py    Tue Jan 22 14:46:59 2008
@@ -117,6 +117,7 @@
         """
         Interface to kaa.beacon: List all files in the directory.
         """
+        # This function is only used by the client
         if recursive:
             return self._beacon_controller().query(parent=self, recursive=True)
         return self._beacon_controller().query(parent=self)
@@ -124,42 +125,49 @@
 
     def scan(self):
         """
-        Request the item to be scanned. (Client API only)
+        Request the item to be scanned.
         Returns either False if not connected or an InProgress object.
         """
+        # This function is only used by the client
         result = self._beacon_controller()._beacon_parse(self)
         if isinstance(result, kaa.InProgress):
             result.connect_once(self._beacon_database_update)
         return result
 
 
+    def __repr__(self):
+        """
+        Convert object to string (usefull for debugging)
+        """
+        s = '<beacon.File %s' % self.filename
+        if not self.url.startswith('file://'):
+            s = '<beacon.File %s' % self.url
+        if self._beacon_data.get('mtime') == None:
+            s += ' (new)'
+        else:
+            s += ' (type=%s)' % str(self._beacon_data.get('type'))
+        return s + '>'
+
+
     # -------------------------------------------------------------------------
-    # Internal API for client and server
+    # Internal API for the server
     # -------------------------------------------------------------------------
 
-    @kaa.yield_execution()
-    def _beacon_listdir(self, cache=False, async=False):
+    def _beacon_listdir(self, cache=False):
         """
         Internal function to list all files in the directory and the overlay
         directory. The result is a list of tuples:
         basename, full filename, is_overlay, stat result
-        This function gets called by the client when doing a dirname query
-        and by the server for the query and inside the parser to get mtime
-        information. If async is True, this function may return an
-        InProgress object and not the results. In that case, connect to this
-        object to get the result later.
         """
         if self._beacon_listdir_cache and cache and \
                self._beacon_listdir_cache[0] + 3 > time.time():
             # use cached result if we have and caching time is less than
             # three seconds ago
-            yield self._beacon_listdir_cache[1:]
-
-        # FIXME: This doesn't hold a reference to items, so what does?
+            return self._beacon_listdir_cache[1:]
 
         # FIXME: this could block for everything except media 1. So this
         # should be done in the hwmon process. But the server doesn't like
-        # an InProgress return.
+        # an InProgress return in the function.
         try:
             # Try to list the overlay directory
             overlay_results = os.listdir(self._beacon_ovdir)
@@ -174,10 +182,9 @@
         except OSError, e:
             log.warning(e)
             self._beacon_listdir_cache = time.time(), [], {}
-            yield [], {}
+            return [], {}
 
         results_file_map = {}
-        counter = 0
         timer = time.time()
 
         for is_overlay, prefix, results in \
@@ -198,15 +205,7 @@
                     # unable to stat file, remove it from list
                     log.error(e)
                     continue
-
                 results_file_map[r] = (r, fullpath, is_overlay, statinfo)
-                counter += 1
-                if async and not counter % 30 and time.time() > timer + 0.04:
-                    # we are in async mode and already use too much time.
-                    # call yield YieldContinue at this point to continue
-                    # later.
-                    timer = time.time()
-                    yield kaa.YieldContinue
 
         # We want to avoid lambda on large data sets, so we sort the keys,
         # which is just a list of files.  This is the common case that sort()
@@ -216,21 +215,7 @@
         result = [ results_file_map[x] for x in keys ]
         # store in cache
         self._beacon_listdir_cache = time.time(), result, results_file_map
-        yield result, results_file_map
-
-
-    def __repr__(self):
-        """
-        Convert object to string (usefull for debugging)
-        """
-        s = '<beacon.File %s' % self.filename
-        if not self.url.startswith('file://'):
-            s = '<beacon.File %s' % self.url
-        if self._beacon_data.get('mtime') == None:
-            s += ' (new)'
-        else:
-            s += ' (type=%s)' % str(self._beacon_data.get('type'))
-        return s + '>'
+        return result, results_file_map
 
 
     def _beacon_mtime(self):

Modified: trunk/beacon/src/item.py
==============================================================================
--- trunk/beacon/src/item.py    (original)
+++ trunk/beacon/src/item.py    Tue Jan 22 14:46:59 2008
@@ -180,7 +180,8 @@
 
     def list(self):
         """
-        Return all subitems to his item.
+        Return all subitems to his item. The return is either an empty list,
+        an InProgress object (server) or a Query object (client).
         """
         if not self._beacon_id:
             return []

Modified: trunk/beacon/src/media.py
==============================================================================
--- trunk/beacon/src/media.py   (original)
+++ trunk/beacon/src/media.py   Tue Jan 22 14:46:59 2008
@@ -88,8 +88,7 @@
         if isinstance(media, kaa.InProgress):
             # This will happen for the client because in the client
             # _beacon_media_information needs to lock the db.
-            yield media
-            media = media.get_result()
+            media = yield media
         prop['beacon.content'] = media['content']
         self._beacon_isdir = False
         if media['content'] == 'file':

Modified: trunk/beacon/src/query.py
==============================================================================
--- trunk/beacon/src/query.py   (original)
+++ trunk/beacon/src/query.py   Tue Jan 22 14:46:59 2008
@@ -205,6 +205,7 @@
             log.info('force data for %s', parent)
             async = parent.scan()
             if isinstance(async, kaa.InProgress):
+                # Not an InProgress object if it is not file.
                 yield async
 
         # we have to wait until we are sure that the db is free for
@@ -212,11 +213,12 @@
         # some time until it tries again. That time is too long, it
         # can take up to two seconds.
         yield self._rpc('db.lock')
-        self.result = self._client._db.query(**query)
-        if isinstance(self.result, kaa.InProgress):
-            yield self.result
-            self.result = self.result.get_result()
-        self._rpc('db.unlock')
+        try:
+            self.result = self._client._db.query(**query)
+            if isinstance(self.result, kaa.InProgress):
+                self.result = yield self.result
+        finally:
+            self._rpc('db.unlock')
 
         self.valid = True
         self.signals['changed'].emit()
@@ -256,8 +258,7 @@
         yield self._rpc('db.lock')
         result = self._client._db.query(**self._query)
         if isinstance(result, kaa.InProgress):
-            yield result
-            result = result.get_result()
+            result = yield result
         self._rpc('db.unlock')
         if send_signal or len(self.result) != len(result):
             # The query result length is different

Modified: trunk/beacon/src/server/crawl.py
==============================================================================
--- trunk/beacon/src/server/crawl.py    (original)
+++ trunk/beacon/src/server/crawl.py    Tue Jan 22 14:46:59 2008
@@ -485,10 +485,7 @@
         subdirs = []
         counter = 0
 
-        result = self._db.query(parent=directory)
-        if isinstance(result, kaa.InProgress):
-            yield result
-            result = result()
+        result = yield self._db.query(parent=directory)
         for child in result:
             if child._beacon_isdir:
                 # add directory to list of files to return
@@ -497,8 +494,7 @@
             # check file
             async = parse(self._db, child, check_image=self._startup)
             if isinstance(async, kaa.InProgress):
-                yield async
-                async = async()
+                async = yield async
             counter += async * 20
             while counter >= 20:
                 counter -= 20
@@ -511,9 +507,7 @@
         if not subdirs:
             # No subdirectories that need to be checked. Add some extra
             # attributes based on the found items (recursive back to parents)
-            result = self._add_directory_attributes(directory)
-            if isinstance(result, kaa.InProgress):
-                yield result
+            yield self._add_directory_attributes(directory)
         yield subdirs
 
 
@@ -528,10 +522,7 @@
         check_attr = data.keys()[:]
         check_attr.remove('length')
 
-        result = self._db.query(parent=directory)
-        if isinstance(result, kaa.InProgress):
-            yield result
-            result = result()
+        result = yield self._db.query(parent=directory)
         for child in result:
             data['length'] += child._beacon_data.get('length', 0) or 0
             for attr in check_attr:
@@ -579,6 +570,4 @@
 
         # check parent
         if directory._beacon_parent.filename in self.monitoring:
-            result = self._add_directory_attributes(directory._beacon_parent)
-            if isinstance(result, kaa.InProgress):
-                yield result
+            yield self._add_directory_attributes(directory._beacon_parent)

Modified: trunk/beacon/src/server/hwmon/client.py
==============================================================================
--- trunk/beacon/src/server/hwmon/client.py     (original)
+++ trunk/beacon/src/server/hwmon/client.py     Tue Jan 22 14:46:59 2008
@@ -81,6 +81,7 @@
     # rpc callbacks
 
     @kaa.rpc.expose('device.add')
+    @kaa.yield_execution()
     def _device_add(self, dev):
         # FIXME: check if the device is still valid
 
@@ -96,7 +97,7 @@
         if not media:
             if not dev.get('volume.is_disc') == True:
                 # fake scanning for other media than rom drives
-                return self._device_scanned(None, dev)
+                yield self._device_scanned(None, dev)
             # scan the disc in background
             self.rpc('device.scan', id).connect(self._device_scanned, dev)
             return
@@ -107,7 +108,7 @@
             self.mount(dev)
             return
 
-        m = self._db.medialist.add(id, dev)
+        m = yield self._db.medialist.add(id, dev)
 
         # create overlay directory structure
         if not os.path.isdir(m.overlay):
@@ -189,4 +190,4 @@
                 mtime = os.stat(dev.get('block.device'))[stat.ST_MTIME]
             dir = self._db.add_object(
                 "dir", name="", parent=('media', mid), media=mid, mtime=mtime)
-        self._device_add(dev)
+        yield self._device_add(dev)

Modified: trunk/beacon/src/server/monitor.py
==============================================================================
--- trunk/beacon/src/server/monitor.py  (original)
+++ trunk/beacon/src/server/monitor.py  Tue Jan 22 14:46:59 2008
@@ -40,6 +40,7 @@
 
 # kaa.beacon imports
 from kaa.beacon.item import Item
+from parser import parse
 
 # get logging object
 log = logging.getLogger('beacon.monitor')
@@ -149,12 +150,9 @@
             changes = self._check_changes + changes
             self._check_changes = []
 
-        current = self._db.query(**self._query)
-        if isinstance(current, kaa.InProgress):
-            self._checking = True
-            yield current
-            current = current()
-            self._checking = False
+        self._checking = True
+        current = yield self._db.query(**self._query)
+        self._checking = False
 
         # The query result length is different, this is a change
         if len(current) != len(self.items):
@@ -209,12 +207,7 @@
         """
         self._checking = True
 
-        current = self._db.query(**self._query)
-        if isinstance(current, kaa.InProgress):
-            yield current
-            current = current()
-        self.items = current
-
+        self.items = yield self._db.query(**self._query)
         if not self.items or not isinstance(self.items[0], Item):
             self._checking = False
             yield False
@@ -228,7 +221,8 @@
                 # stop it and continue in the next step
                 yield YieldContinue
             # TODO: maybe also check parents?
-            if i._beacon_mtime() != i._beacon_data.get('mtime'):
+            mtime = i._beacon_mtime()
+            if mtime != i._beacon_data.get('mtime'):
                 changed.append(i)
 
         if not changed:
@@ -246,7 +240,7 @@
 
         for pos, item in enumerate(changed):
             self.notify_client('progress', pos+1, len(changed), item.url)
-            async = item.scan()
+            async = parse(item)
             if isinstance(async, kaa.InProgress):
                 yield async
             if not self._running:
@@ -257,11 +251,7 @@
 
         # The client will update its query on this signal, so it should
         # be safe to do the same here. *cross*fingers*
-        current = self._db.query(**self._query)
-        if isinstance(current, kaa.InProgress):
-            yield current
-            current = current()
-        self.items = current
+        self.items = yield self._db.query(**self._query)
         # Do not send 'changed' signal here. The db was changed and the
         # master notification will do the rest. Just to make sure it will
         # happen, start a Timer

Modified: trunk/beacon/src/server/parser.py
==============================================================================
--- trunk/beacon/src/server/parser.py   (original)
+++ trunk/beacon/src/server/parser.py   Tue Jan 22 14:46:59 2008
@@ -73,14 +73,15 @@
     extention_plugins[ext].append(function)
 
 
[EMAIL PROTECTED]()
 def parse(db, item, check_image=False):
     """
     Main beacon parse function. Return the load this function produced:
     0 == nothing done
-    1 == normal parsing
-    2 == thumbnail storage
-    This function may return an InProgress object
+    1 == normal parsing (as InProgress object)
+    2 == thumbnail storage (as InProgress object)
     """
+
     mtime = item._beacon_mtime()
     if mtime == None:
         if item.isdir() or item.isfile():
@@ -103,9 +104,9 @@
 
     if parent._beacon_id and not item._beacon_id:
         # check if the item is in the db now from a different
-        # list of items. FIXME: this kind of query would never
-        # return an InProgress object! This has to be made clear.
-        r = db.query(name=item._beacon_data['name'], parent=parent)
+        # list of items.
+        r = db.query_name_and_parent(name=item._beacon_data['name'],
+                                     parent=parent_beacon_id)
         if r:
             item._beacon_database_update(r[0]._beacon_data)
 
@@ -126,8 +127,7 @@
         else:
             return 0
 
-    # looks like we have more to do. Start the yield_execution
-    # part of the parser
+    # looks like we have more to do. Start the yield_execution part of the 
parser
     return _parse(db, item, mtime)
 
 
@@ -154,8 +154,7 @@
         # parsing process. maye this item was in the db already
         r = parse(db, parent)
         if isinstance(r, kaa.InProgress):
-            yield r
-            yield r.get_result()
+            r = yield r
         yield r
 
 
@@ -317,10 +316,7 @@
             yield produced_load
 
         # delete all known tracks before adding new
-        result = db.query(parent=item)
-        if isinstance(result, kaa.InProgress):
-            yield result
-            result = result.get_result()
+        result = yield db.query(parent=item)
         for track in result:
             db.delete_object(track)
 

Modified: trunk/beacon/src/server/server.py
==============================================================================
--- trunk/beacon/src/server/server.py   (original)
+++ trunk/beacon/src/server/server.py   Tue Jan 22 14:46:59 2008
@@ -299,10 +299,7 @@
         # TODO: check if directory is already being monitored.
 
         directory = os.path.realpath(directory)
-        data = self._db.query(filename = directory)
-        if isinstance(data, kaa.InProgress):
-            yield data
-            data = data()
+        data = yield self._db.query(filename = directory)
         items = []
         for i in data.get_ancestors():
             if i._beacon_id:
@@ -325,10 +322,7 @@
         log.info('add monitor %s', query)
         if query and 'parent' in query:
             type, id = query['parent']
-            result = self._db.query(type=type, id=id)[0]
-            if isinstance(result, kaa.InProgress):
-                yield result
-                result = result()
+            result = yield self._db.query(type=type, id=id)[0]
             query['parent'] = result
 
         for id, client, monitors in self._clients:
@@ -380,10 +374,7 @@
         """
         Request item data.
         """
-        data = self._db.query(filename=filename)
-        if isinstance(data, kaa.InProgress):
-            yield data
-            data = data()
+        data = yield self._db.query(filename=filename)
         items = []
         for i in data.get_ancestors():
             if i._beacon_id:
@@ -402,10 +393,7 @@
         """
         Create a new item.
         """
-        data = self._db.query(id=parent)
-        if isinstance(data, kaa.InProgress):
-            yield data
-            data = data()
+        data = yield self._db.query(id=parent)
         while self._db.read_lock.is_locked():
             yield self._db.read_lock.yield_unlock()
         yield self._db.add_object(type, parent=parent, **kwargs)

Modified: trunk/epg/src/__init__.py
==============================================================================
--- trunk/epg/src/__init__.py   (original)
+++ trunk/epg/src/__init__.py   Tue Jan 22 14:46:59 2008
@@ -64,7 +64,7 @@
 
 def get_channels(sort=False):
     """
-    Return a list of all channels.
+    Return a list of all channels as InProgress obejct
     """
     if guide.status == DISCONNECTED:
         connect()
@@ -73,7 +73,7 @@
 
 def get_channel(name):
     """
-    Return the channel with the given name.
+    Return the channel with the given name as InProgress obejct
     """
     if guide.status == DISCONNECTED:
         connect()

Modified: trunk/epg/src/client.py
==============================================================================
--- trunk/epg/src/client.py     (original)
+++ trunk/epg/src/client.py     Tue Jan 22 14:46:59 2008
@@ -150,11 +150,11 @@
     def search(self, channel=None, time=None, **kwargs):
         """
         Search the db. This will call the search function on server side using
-        kaa.ipc. This function will always return an InProgress object, even 
when
-        the client is disconnected.
+        kaa.ipc. This function will always return an InProgress object or raise
+        an exception if the client is disconnected.
         """
         if self.status == DISCONNECTED:
-            # make sure we always return InProgress
+            # TODO: make sure we always return InProgress
             raise SystemError('Client is disconnected')
 
         while self.status == CONNECTING:
@@ -183,10 +183,9 @@
                 kwargs["start"] = kaa.db.QExpr(">=", (int(start) - max))
                 
         query_data = self.server.rpc('guide.query', type='program', **kwargs)
-        # wait for the rpc to finish
+        # wait for the rpc to finish and get result
         yield query_data
-        # get data
-        query_data = query_data()
+        query_data = query_data.get_result()
 
         # Convert raw search result data
         if kwargs.get('attrs'):

Modified: trunk/epg/src/server.py
==============================================================================
--- trunk/epg/src/server.py     (original)
+++ trunk/epg/src/server.py     Tue Jan 22 14:46:59 2008
@@ -187,10 +187,15 @@
                 continue
 
             log.info('Updating backend %s', backend)
-            # Backend's update() must be threaded, and so will return an
-            # InProgress object that we now yield.
-            yield sources[backend].update(self, *args, **kwargs)
-
+            # Backend's update() MUST return an InProgress object
+            try:
+                # The yield may crash on Python 2.5 using throw
+                # An error message will not be visible for 2.4
+                yield sources[backend].update(self, *args, **kwargs)
+            except (KeyboardInterrupt, SystemExit):
+                sys.exit(0)
+            except Exception, e:
+                log.exception('Backend %s failed' % backend)
         if not backends:
             log.warning('No valid backends specified for update.')
             return

Modified: trunk/feedmanager/setup.py
==============================================================================
--- trunk/feedmanager/setup.py  (original)
+++ trunk/feedmanager/setup.py  Tue Jan 22 14:46:59 2008
@@ -29,6 +29,11 @@
 # python imports
 import sys
 
+# We require python 2.5 or later, so complain if that isn't satisfied.
+if sys.version.split()[0] < '2.5':
+    print "Python 2.5 or later required."
+    sys.exit(1)
+
 try:
     # kaa base imports
     from kaa.distribution.core import Extension, setup

Modified: trunk/feedmanager/src/core.py
==============================================================================
--- trunk/feedmanager/src/core.py       (original)
+++ trunk/feedmanager/src/core.py       Tue Jan 22 14:46:59 2008
@@ -240,14 +240,9 @@
                         continue
 
                 if os.path.isfile(filename):
-                    item = kaa.beacon.get(filename)
-                    if isinstance(item, kaa.InProgress):
-                        yield item
-                        item = item.get_result()
+                    item = yield kaa.beacon.get(filename)
                     if not item.scanned():
-                        async = item.scan()
-                        if isinstance(async, kaa.InProgress):
-                            yield async
+                        yield item.scan()
                     if 'date' in entry:
                         item['timestamp'] = entry['date']
                     for key in ('title', 'description'):
@@ -297,8 +292,9 @@
         allurls = [ e[0] for e in self._entries ]
         listing = beacondir.list()
         if isinstance(listing, kaa.InProgress):
-            yield listing
-            listing = listing.get_result()
+            # FIXME: can this happen? Shouldn't list always return a Query
+            # object and that may or may not be finished?
+            listing = yield listing
         for entry in listing:
             if entry.url in allurls:
                 log.info('delete %s', entry.url)

Modified: trunk/feedmanager/src/rss.py
==============================================================================
--- trunk/feedmanager/src/rss.py        (original)
+++ trunk/feedmanager/src/rss.py        Tue Jan 22 14:46:59 2008
@@ -63,10 +63,7 @@
         """
         Iterate over feed entries.
         """
-        feed = feedparser(self.url)
-        yield feed
-        feed = feed.get_result()
-
+        feed = yield feedparser(self.url)
         if not feed.entries:
             log.error('no entries in %s' % self.url)
             raise StopIteration
@@ -79,10 +76,7 @@
         if feedimage:
             # FIXME: beacon does not thumbnail the image without
             # a rescan of the directory!
-            feedimage = self._get_image(feedimage)
-            if isinstance(feedimage, kaa.InProgress):
-                yield feedimage
-                feedimage = feedimage.get_result()
+            feedimage = yield self._get_image(feedimage)
 
         # real iterate
         for f in feed.entries:

-------------------------------------------------------------------------
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