文件太大要导入?

时间:2014-01-27 18:47:37

标签: python python-2.7

我刚刚编写此代码来获取wireshark mac oui数据库,我收到以下错误:

Traceback (most recent call last):
  File "init.py", line 38, in <module>
    main()
  File "init.py", line 27, in main
    import maclist
  File "/home/synthetica/WiJam/maclist.py", line 23753
    'FC:F6:4

但是,这不是该行文件的内容。这是python intepreter的限制,我忽略了什么,或其他什么?

init.py:

def main():
    #init
     #Load config.
    import localconfig
    print localconfig.name
     #update mac adress db, if at all possible:
    try:
        import maclist
    except:
        import urllib2
        print "Fetching MAC adress db."
        try:
            maclist = urllib2.urlopen(localconfig.url)
        else:
            fl = open("maclist.py","w")
            fl.write("#maclist.py generated by "+localconfig.name+"\n")
            print "Generating maclist.py"
            for line in maclist:
                if "#" in line: line=line[:line.index("#")]
                line = line.split()
                if line and "-" not in line[0]:
                    line=[repr(part) for part in line]
                    line = "=".join(line)
                    fl.write("=".join(line.split())+"\n")
    import maclist



 #start browser

#start web interface
 #handle web interface commands
 #display web interface

if __name__=="__main__":
    main()

localconfig.py

version = "0.3"
name = "Synth's WiJam (version "+version+")"

#maclist related:
url = "https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf;hb=HEAD"

任何线索?

@bren maclist.py:不是全部,天哪没有。这是20k +行。

'FC:E1:92'='SichuanJ'
'FC:E1:D9'='StableIm'
'FC:E2:3F'='ClayPaky'
'FC:E5:57'='Nokia'
'FC:E8:92'='Hangzhou'
'FC:ED:B9'='Arrayent'
'FC:F1:CD'='Optex-Fa'
'FC:F5:28'='ZyxelCom'
'FC:F6:47'='Fiberhom'
'FC:F8:AE'='IntelCor'
'FC:F8:B7'='TronteqE'
'FC:FA:F7'='Shanghai'
'FC:FB:FB'='Cisco'

1 个答案:

答案 0 :(得分:3)

将maclist.py重写为适当的python语法,例如:

hosts={} 
hosts['FC:FA:F7']='Shanghai'
hosts['FC:FB:FB']='Cisco'

等等。