向无线控制器发送数据的Python程序

向无线控制器发送数据的Python程序,python,host,juniper-network-connect,Python,Host,Juniper Network Connect,我已经实现了一个python程序,将数据发送到JuniperWLC100控制器。我必须使用预先编写的juniperwlc文件向控制器发送数据。错误是缺少主机参数。我不认为我们需要一个主机参数与我通过查看程序已经传递的3个参数一起发送。查看jnpr.wlc代码的github页面为。请花点时间帮助我。谢谢 我得到的错误是: from jnpr.wlc import WirelessLanController as WLC import sys import urllib2 def WLC_login

我已经实现了一个python程序,将数据发送到JuniperWLC100控制器。我必须使用预先编写的juniperwlc文件向控制器发送数据。错误是缺少主机参数。我不认为我们需要一个主机参数与我通过查看程序已经传递的3个参数一起发送。查看jnpr.wlc代码的github页面为。请花点时间帮助我。谢谢

我得到的错误是:

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()
tracedump是:

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

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

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

您不应该在登录字典中使用主机名而不是主机名吗?我不知道Juniper,但我快速阅读了一下文档。。我想可能就是这样。。在你发布的git hub链接上,我看到了这个。。wlc=wlc user='jeremy',host='192.168.56.191',password='logmein'您好,谢谢您的快速回复。我按照您的建议更改了wlc以传递值,我收到了一个意外错误:意外错误:……请帮助这就是全部错误。意外错误:在使用循环时重复了两次。谢谢。您的except语句掩盖了错误。请在打印后添加加薪意外错误:,sys.exc_info[0]当我在打印后添加加薪时,我遇到了很多错误,最终以urllib2.URLError结束:我们在这里偏离了轨道,但请尝试:wlc=wlc user=xxxxx,host='172.31.99.14',password=xxxxx,http=http