使用python-cod连接到路由器时出错

2024-09-27 21:33:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用上面的代码连接到某个路由器,我使用juniperj2320.py模块,在测试文件中 我正在使用来自此http://subversion.assembla.com/svn/clauzsistel08/trunk/dist/的代码基

#!/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)

但是我得到了下面的错误

^{pr2}$

绝对没有线索知道这里发生了什么!任何帮助都将不胜感激

谢谢


Tags: 模块文件代码frompyimporthttpsys
2条回答

这有点冒险,因为我不熟悉您所使用的模块,但是根据回溯,看起来构造函数需要一个类似文件的对象,而不仅仅是文件路径。试试这个。在

SERIALDEVICE = '/dev/ttyUSB0'

# Now configure the router
try:
    router = JuniperJ2320(open(SERIALDEVICE))

让pexpect驱动minicom这样的串行程序,而不是编写自己的串行通信程序会更容易吗?在

相关问题 更多 >

    热门问题