我嘗試使用上面的代碼連接到某些路由器,我使用juniperj2320.py模塊和測試文件我有 正在使用的代碼基礎,從這個http://subversion.assembla.com/svn/clauzsistel08/trunk/dist/錯誤連接與Python代碼到路由器時
#!/usr/bin/python
from localconf import *
from juniperj2320 import *
import sys
import traceback
SERIALDEVICE = '/dev/ttyUSB0'
# Now configure the router
try:
router = JuniperJ2320(SERIALDEVICE)
except RouterConfigurationException, err:
print "Router configuration error: ", err
print "Please try again."
sys.exit(1)
但我得到這個下面的錯誤
./test.py > /root/pyserial-2.6/examples/serialrouter.py(37)__init__() -> serial.Serial.__init__(self, serialdevice, baudrate=baudrate, \ (Pdb) c Traceback (most recent call last): File "./test.py", line 30, in router = JuniperJ2320(SERIALDEVICE) File "/root/pyserial-2.6/examples/juniperj2320.py", line 32, in __init__ BYTESIZE, PARITY, STOPBITS, TIMEOUT) File "/root/pyserial-2.6/examples/serialrouter.py", line 44, in __init__ fdpexpect.fdspawn.__init__(self, self.fileno()) File "/usr/lib/python2.6/site-packages/fdpexpect.py", line 40, in __init__ spawn.__init__(self, None, args, timeout, maxread, searchwindowsize, logfile ) File "/usr/lib/python2.6/site-packages/pexpect.py", line 412, in __init__ self.closed = True # File-like object. AttributeError: can't set attribute
,絕對線索少笏發生在這裏!任何幫助會不勝感激
感謝
我認爲,我們不能使用Pexpect的驅動小型機一個可以使用的runScript爲此目的與小型機...我嘗試使用Pexpect的和pyserial但有些TIEMS Pexpect的不給我預期的效果!所以寫了我自己的while循環等待。 – bana