コード例 #1
0
ファイル: data.py プロジェクト: loofool/switzerland
def load_services(filename):
    spaces = re.compile("[ \t]+|\n")
    tdct = DADict(_name="%s-tcp" % filename)
    udct = DADict(_name="%s-udp" % filename)
    try:
        f = open(filename)
        for l in f:
            try:
                shrp = l.find("#")
                if shrp >= 0:
                    l = l[:shrp]
                l = l.strip()
                if not l:
                    continue
                lt = tuple(re.split(spaces, l))
                if len(lt) < 2 or not lt[0]:
                    continue
                if lt[1].endswith("/tcp"):
                    tdct[lt[0]] = int(lt[1].split('/')[0])
                elif lt[1].endswith("/udp"):
                    udct[lt[0]] = int(lt[1].split('/')[0])
            except Exception, e:
                log_loading.warning("Couldn't file [%s]: line [%r] (%s)" %
                                    (filename, l, e))
        f.close()
コード例 #2
0
ファイル: data.py プロジェクト: Pojen-Huang/trex-core
def load_services(filename):
    spaces = re.compile("[ \t]+|\n")
    tdct=DADict(_name="%s-tcp"%filename)
    udct=DADict(_name="%s-udp"%filename)
    return tdct,udct
    try:
        f=open(filename)
        for l in f:
            try:
                shrp = l.find("#")
                if  shrp >= 0:
                    l = l[:shrp]
                l = l.strip()
                if not l:
                    continue
                lt = tuple(re.split(spaces, l))
                if len(lt) < 2 or not lt[0]:
                    continue
                if lt[1].endswith("/tcp"):
                    tdct[lt[0]] = int(lt[1].split('/')[0])
                elif lt[1].endswith("/udp"):
                    udct[lt[0]] = int(lt[1].split('/')[0])
            except Exception,e:
                log_loading.warning("Couldn't file [%s]: line [%r] (%s)" % (filename,l,e))
        f.close()
コード例 #3
0
ファイル: base_classes.py プロジェクト: 437049211/PyQYT
 def __new__(cls, name, bases, dct):
     from error import log_loading
     import traceback
     try:
         for tb in traceback.extract_stack()+[("??",-1,None,"")]:
             f,l,_,line = tb
             if line.startswith("class"):
                 break
     except:
         f,l="??",-1
         raise
     log_loading.warning("Deprecated (no more needed) use of NewDefaultValues  (%s l. %i)." % (f,l))
     
     return super(NewDefaultValues, cls).__new__(cls, name, bases, dct)
コード例 #4
0
 def __new__(cls, name, bases, dct):
     from error import log_loading
     import traceback
     try:
         for tb in traceback.extract_stack()+[("??",-1,None,"")]:
             f,l,_,line = tb
             if line.startswith("class"):
                 break
     except:
         f,l="??",-1
         raise
     log_loading.warning("Deprecated (no more needed) use of NewDefaultValues  (%s l. %i)." % (f,l))
     
     return super(NewDefaultValues, cls).__new__(cls, name, bases, dct)
コード例 #5
0
ファイル: data.py プロジェクト: Pojen-Huang/trex-core
def load_manuf(filename):
    try:
        manufdb=ManufDA(_name=filename)
        for l in open(filename):
            try:
                l = l.strip()
                if not l or l.startswith("#"):
                    continue
                oui,shrt=l.split()[:2]
                i = l.find("#")
                if i < 0:
                    lng=shrt
                else:
                    lng = l[i+2:]
                manufdb[oui] = shrt,lng
            except Exception,e:
                log_loading.warning("Couldn't parse one line from [%s] [%r] (%s)" % (filename, l, e))
    except IOError:
        #log_loading.warning("Couldn't open [%s] file" % filename)
        pass
    return manufdb
コード例 #6
0
ファイル: data.py プロジェクト: unix1010/isf-1
def load_manuf(filename):
    try:
        manufdb=ManufDA(_name=filename)
        for l in open(filename):
            try:
                l = l.strip()
                if not l or l.startswith("#"):
                    continue
                oui,shrt=l.split()[:2]
                i = l.find("#")
                if i < 0:
                    lng=shrt
                else:
                    lng = l[i+2:]
                manufdb[oui] = shrt,lng
            except Exception,e:
                log_loading.warning("Couldn't parse one line from [%s] [%r] (%s)" % (filename, l, e))
    except IOError:
        #log_loading.warning("Couldn't open [%s] file" % filename)
        pass
    return manufdb