summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-05-15 01:36:46 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-05-15 01:36:46 +0000
commit6ec4573ccd6f67234b81a8aa9a6dc1ca024a21d6 (patch)
tree88a804b9c9f04e35a6b4f98cce6bd99a986e2203
parentaeca73b5528b8573f0bb499772ff90e5f54f416f (diff)
downloadbcfg2-6ec4573ccd6f67234b81a8aa9a6dc1ca024a21d6.tar.gz
bcfg2-6ec4573ccd6f67234b81a8aa9a6dc1ca024a21d6.tar.bz2
bcfg2-6ec4573ccd6f67234b81a8aa9a6dc1ca024a21d6.zip
Fix fam tracebacks for Ticket #650
Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5234 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/FileMonitor.py38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/lib/Server/FileMonitor.py b/src/lib/Server/FileMonitor.py
index b8947f8f1..30e6d4d82 100644
--- a/src/lib/Server/FileMonitor.py
+++ b/src/lib/Server/FileMonitor.py
@@ -1,5 +1,7 @@
+import logging
+import os
+import stat
from time import sleep, time
-import logging, os, stat
logger = logging.getLogger('Bcfg2.Server.FileMonitor')
@@ -26,11 +28,20 @@ class Event(object):
class GaminEvent(Event):
- '''This class provides an event analogous to python-fam events based on gamin sources'''
+ '''
+ This class provides an event analogous to
+ python-fam events based on gamin sources
+ '''
def __init__(self, request_id, filename, code):
Event.__init__(self, request_id, filename, code)
- action_map = {GAMCreated: 'created', GAMExists: 'exists', GAMChanged: 'changed',
- GAMDeleted: 'deleted', GAMEndExist: 'endExist', GAMMoved: 'moved'}
+ action_map = {}
+ if 'fam' not in available and 'gamin' not in available:
+ pass
+ else:
+ # Only works if Gamin or Fam is present
+ action_map = {GAMCreated: 'created', GAMExists: 'exists',
+ GAMChanged: 'changed', GAMDeleted: 'deleted',
+ GAMEndExist: 'endExist', GAMMoved: 'moved'}
if code in action_map:
self.action = action_map[code]
@@ -89,7 +100,10 @@ class FileMonitor(object):
sleep(0.5)
class Fam(FileMonitor):
- '''The fam object is a set of callbacks for file alteration events (FAM support)'''
+ '''
+ The fam object is a set of callbacks for
+ file alteration events (FAM support)
+ '''
def __init__(self, debug=False):
FileMonitor.__init__(self, debug)
@@ -116,7 +130,10 @@ class Fam(FileMonitor):
return self.fm.nextEvent()
class Gamin(FileMonitor):
- '''The fam object is a set of callbacks for file alteration events (Gamin support)'''
+ '''
+ The fam object is a set of callbacks for
+ file alteration events (Gamin support)
+ '''
def __init__(self, debug=False):
FileMonitor.__init__(self, debug)
self.mon = WatchMonitor()
@@ -150,7 +167,10 @@ class Gamin(FileMonitor):
return self.events.pop()
class Pseudo(FileMonitor):
- '''The fam object is a set of callbacks for file alteration events (FAM support)'''
+ '''
+ The fam object is a set of callbacks for
+ file alteration events (static monitor support)
+ '''
def __init__(self, debug=False):
FileMonitor.__init__(self, debug=False)
@@ -179,7 +199,7 @@ class Pseudo(FileMonitor):
self.handles[handleID] = obj
return handleID
-
+
available = {}
try:
from gamin import WatchMonitor, GAMCreated, GAMExists, GAMEndExist, GAMChanged, GAMDeleted, GAMMoved
@@ -191,7 +211,7 @@ try:
import _fam
available['fam'] = Fam
except ImportError:
- pass
+ print("Gamin or Fam not found. Loading Pseudo FileMonitor.")
available['pseudo'] = Pseudo
for fdrv in ['gamin', 'fam', 'pseudo']: