1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00
roopa d40e96ee4e man page cleanup + cleanup + minor fixes
Ticket: CM-1438
Reviewed By:
Testing Done: Tested ifupdown sanity
2014-04-25 16:09:14 -07:00

27 lines
600 B
Python

#!/usr/bin/python
import os
import fcntl
class utils():
@classmethod
def importName(cls, modulename, name):
""" Import a named object """
try:
module = __import__(modulename, globals(), locals(), [name])
except ImportError:
return None
return getattr(module, name)
@classmethod
def lockFile(cls, lockfile):
try:
fp = os.open(lockfile, os.O_CREAT | os.O_TRUNC | os.O_WRONLY)
fcntl.flock(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
return False
return True