【问题标题】:Python Program to send data to A wireless Controller将数据发送到无线控制器的 Python 程序
【发布时间】:2015-09-28 05:35:57
【问题描述】:

我已经实现了一个 python 程序来将数据发送到瞻博网络 wlc100 控制器。我必须使用预先编写的瞻博网络 wlc 文件将数据发送到控制器。错误是缺少“主机”参数。我认为我们不需要将主机参数与我通过查看程序已经传递的 3 个参数一起发送。查看jnpr.wlc代码的github页面是https://github.com/Juniper/py-jnpr-wlc。请花点时间帮助我。谢谢。

我得到的错误是:

from jnpr.wlc import WirelessLanController as WLC
import sys
import urllib2
def WLC_login():
    login = {
        'user': 'xxxxx',
        'hostname': '172.31.99.14',
        'password': 'xxxxx',
        }
    wlc = WLC( login )
    try_again = 3
    login_ok = False
    while try_again > 1:
        try:
            wlc.open()
            login_ok = True
            print("Login successful")
            break;
        except:
            try_again-=1
            print "Unexpected error:", sys.exc_info()[0]
    if not login_ok:
        sys.exit(1)
    return wlc

WLC_login()

跟踪转储是:

Traceback (most recent call last):

File "C:/Python27/py-jnpr-wlc-master/new.py", line 27, in <module>
    WLC_login()

File "C:/Python27/py-jnpr-wlc-master/new.py", line 11, in WLC_login
    wlc = WLC( login )

File "C:\Python27\lib\site-packages\jnpr_wlc-0.0.1-py2.7.egg\jnpr\wlc\wlc.py", line 160, in __init__
    assert (_a in kvargs), ("Missing required param: %s" % _a)
AssertionError: Missing required param: host

【问题讨论】:

  • 您不应该在“登录”字典中使用“主机”而不是“主机名”吗?我对瞻博网络一无所知,但快速阅读了文档..我认为可能是这样..在您发布的 git hub 链接上我看到了这个..“wlc = WLC(user='jeremy', host=' 192.168.56.191', 密码='logmein')"

标签: python host juniper-network-connect


【解决方案1】:

我不确定您是否打算将 dict 作为参数发送给 WLC()。虽然可以通过这种方式发送 kwargs,但我认为您真正想要做的是:

wlc = WLC( user="xxxxx", host='172.31.99.14', password="xxxxx" )

【讨论】:

  • 您好,感谢您的快速回复。我按照您的建议更改了 wlc 以传递值,但出现意外错误: 意外错误:....请帮忙
  • 这就是整个错误。意外错误: 在我使用循环时重复了两次。谢谢。
  • 您的 except 语句掩盖了错误。请在print "Unexpected error:", sys.exc_info()[0]之后添加raise
  • 当我在 print 后添加 raise 时出现了很多错误,最终以 urllib2.URLError:
  • 我们要离开这里的滑雪道但是试试看:wlc = WLC( user="xxxxx", host='172.31.99.14', password="xxxxx", http="http" )
猜你喜欢
  • 2016-11-15
  • 1970-01-01
  • 1970-01-01
  • 2020-08-21
  • 1970-01-01
  • 2017-07-07
  • 2017-03-11
  • 2016-10-04
  • 2018-01-18
相关资源
最近更新 更多