Revision e948770c lib/utils.py

b/lib/utils.py
42 42
import resource
43 43
import logging
44 44
import signal
45
import imp
46 45

  
47 46
from cStringIO import StringIO
48 47

  
......
1995 1994
  return value
1996 1995

  
1997 1996

  
1998
def LoadModule(filename):
1999
  """Loads an external module by filename.
2000

  
2001
  Use this function with caution. Python will always write the compiled source
2002
  to a file named "${filename}c".
2003

  
2004
  @type filename: string
2005
  @param filename: Path to module
2006

  
2007
  """
2008
  (name, ext) = os.path.splitext(filename)
2009

  
2010
  fh = open(filename, "U")
2011
  try:
2012
    return imp.load_module(name, fh, filename, (ext, "U", imp.PY_SOURCE))
2013
  finally:
2014
    fh.close()
2015

  
2016

  
2017 1997
class FileLock(object):
2018 1998
  """Utility class for file locks.
2019 1999

  

Also available in: Unified diff