Revision 2635bb04

b/lib/utils/io.py
72 72
  return detail
73 73

  
74 74

  
75
class FileStatHelper:
76
  """Helper to store file handle's C{fstat}.
77

  
78
  Useful in combination with L{ReadFile}'s C{preread} parameter.
79

  
80
  """
81
  def __init__(self):
82
    """Initializes this class.
83

  
84
    """
85
    self.st = None
86

  
87
  def __call__(self, fh):
88
    """Calls C{fstat} on file handle.
89

  
90
    """
91
    self.st = os.fstat(fh.fileno())
92

  
93

  
75 94
def ReadFile(file_name, size=-1, preread=None):
76 95
  """Reads a file.
77 96

  
b/lib/watcher/__init__.py
410 410
                                  for inst in instances])
411 411

  
412 412

  
413
class _StatCb:
414
  """Helper to store file handle's C{fstat}.
415

  
416
  """
417
  def __init__(self):
418
    """Initializes this class.
419

  
420
    """
421
    self.st = None
422

  
423
  def __call__(self, fh):
424
    """Calls C{fstat} on file handle.
425

  
426
    """
427
    self.st = os.fstat(fh.fileno())
428

  
429

  
430 413
def _ReadInstanceStatus(filename):
431 414
  """Reads an instance status file.
432 415

  
......
440 423
  """
441 424
  logging.debug("Reading per-group instance status from '%s'", filename)
442 425

  
443
  statcb = _StatCb()
426
  statcb = utils.FileStatHelper()
444 427
  try:
445 428
    content = utils.ReadFile(filename, preread=statcb)
446 429
  except EnvironmentError, err:

Also available in: Unified diff