示例#1
0
 def _save_blacklist(self):
     blpath = environ.homepath('plblacklist')
     bl = open(blpath, "w")
     try:
         bl.writelines(
             map('%s\n'.__mod__, self._blacklist))
     finally:
         bl.close()
示例#2
0
文件: util.py 项目: nfvproject/nepi
def appendBlacklist(node_ids):
    if not isinstance(node_ids, list):
        node_ids = [node_ids]

    blpath = environ.homepath('plblacklist')
    bl = open(blpath, "a")

    try:
        for node_id in node_ids:
            bl.write("%s\n" % (node_id, ))
    finally:
        bl.close()
示例#3
0
文件: util.py 项目: nfvproject/nepi
def appendBlacklist(node_ids):
    if not isinstance(node_ids, list):
        node_ids = [ node_ids ]
    
    blpath = environ.homepath('plblacklist')
    bl = open(blpath, "a")
    
    try:
        for node_id in node_ids:
            bl.write("%s\n" % (node_id,))
    finally:
        bl.close()
示例#4
0
文件: util.py 项目: nfvproject/nepi
def filterBlacklist(candidates):
    blpath = environ.homepath('plblacklist')

    try:
        bl = open(blpath, "r")
    except:
        return candidates

    try:
        blacklist = set(map(int, map(str.strip, bl.readlines())))
        return [x for x in candidates if x not in blacklist]
    finally:
        bl.close()
示例#5
0
 def _load_blacklist(self):
     blpath = environ.homepath('plblacklist')
     
     try:
         bl = open(blpath, "r")
     except:
         self._blacklist = set()
         return
         
     try:
         self._blacklist = set(
             map(str.strip, bl.readlines())
         )
     finally:
         bl.close()
示例#6
0
文件: util.py 项目: nfvproject/nepi
def filterBlacklist(candidates):
    blpath = environ.homepath('plblacklist')
    
    try:
        bl = open(blpath, "r")
    except:
        return candidates
        
    try:
        blacklist = set(
            map(int,
                map(str.strip, bl.readlines())
            )
        )
        return [ x for x in candidates if x not in blacklist ]
    finally:
        bl.close()