Author: dmeyer
Date: Tue Jan  9 16:58:35 2007
New Revision: 2369

Added:
   trunk/beacon/src/server/utils.py
Modified:
   trunk/beacon/src/server/crawl.py

Log:
move bursthandler to utils

Modified: trunk/beacon/src/server/crawl.py
==============================================================================
--- trunk/beacon/src/server/crawl.py    (original)
+++ trunk/beacon/src/server/crawl.py    Tue Jan  9 16:58:35 2007
@@ -43,6 +43,7 @@
 from parser import parse
 from config import config
 import cpuinfo
+import utils
 
 # get logging object
 log = logging.getLogger('beacon.crawler')
@@ -83,37 +84,6 @@
             self._inotify.ignore(dirname[:-1])
 
 
-class BurstHandler(dict):
-
-    def __init__(self, callback):
-        self._ts = {}
-        self._timer = kaa.notifier.WeakTimer(self._poll)
-        self._timer.start(config.crawler.growscan)
-        self._callback = callback
-        
-    def stop(self):
-        self._timer.stop()
-        self._ts = {}
-
-    def remove(self, name):
-        if not name in self._ts:
-            return
-        del self._ts[name]
-
-    def active(self, name):
-        if not name in self._ts:
-            self._ts[name] = False
-            return False
-        self._ts[name] = True
-        return True
-        
-    def _poll(self):
-        ts = self._ts
-        self._ts = {}
-        for name in [ name for name, needed in ts.items() if needed ]:
-            self._callback(INotify.MODIFY, name)
-
-                
 class Crawler(object):
     """
     Class to crawl through a filesystem and check for changes. If inotify
@@ -134,7 +104,9 @@
 
         # set up inotify
         self._inotify = None
-        self._bursthandler = BurstHandler(self._inotify_event)
+        cb = kaa.notifier.WeakCallback(self._inotify_event, INotify.MODIFY)
+        cb.set_user_args_first(True)
+        self._bursthandler = utils.BurstHandler(config.crawler.growscan / 10, 
cb)
         if use_inotify:
             try:
                 self._inotify = INotify()

Added: trunk/beacon/src/server/utils.py
==============================================================================
--- (empty file)
+++ trunk/beacon/src/server/utils.py    Tue Jan  9 16:58:35 2007
@@ -0,0 +1,69 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# utils.py - Some utils for the server
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2007 Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+__all__ = [ 'BurstHandler' ]
+
+# kaa imports
+import kaa.notifier
+
+class BurstHandler(dict):
+
+    def __init__(self, interval, callback):
+        self._ts = {}
+        self._timer = kaa.notifier.WeakTimer(self._poll)
+        self._timer.start(interval)
+        self._callback = callback
+
+
+    def stop(self):
+        self._timer.stop()
+        self._ts = {}
+
+
+    def remove(self, name):
+        if not name in self._ts:
+            return
+        del self._ts[name]
+
+
+    def active(self, name):
+        if not name in self._ts:
+            self._ts[name] = False
+            return False
+        self._ts[name] = True
+        return True
+
+
+    def _poll(self):
+        ts = self._ts
+        self._ts = {}
+        for name in [ name for name, needed in ts.items() if needed ]:
+            self._callback(name)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to