wlst 身份验证异常再次提示用户
我编写了几个 wlst 脚本,它们按预期工作。该脚本首先提示用户输入用户名/密码,连接到管理服务器,然后执行任务(部署、启动/关闭等)。
我遇到的问题是在第一步 - 如果用户输入了错误的用户名/密码,我希望脚本再次提示该信息。请注意,我希望用户仅在用户名/密码不正确时收到第二次提示,而不是在管理服务器关闭时收到提示。
我正在尝试以下代码,但它没有按预期工作(它永远不会进入第一个 except 块)。显然,我缺乏 OOPS 编程经验阻碍了这个简单任务的完成。希望有人可以帮助完成这一步。
尝试:
connect(username, password, 't3://ADMIN_SERVER:ADMIN_PORT')
除了SecurityException:
print '\nAuthentication error, add logic to retry\n"
exit(exitcode=1)
除了:(
print "\n\n ALL OTHER ERRORS \n\n "
我也尝试过NamingException,AuthenticationException代替SecurityException,但它也没有帮助)
I have written a couple of wlst scripts which work as expected. The script starts by prompting the user for a username/password, connects to the admin server and then performs the tasks (deployment, startup/shutdown etc etc).
The problem I am having is at the first step - if the user enters an incorrect username/password, I want the script to prompt it one more time for this information. Note that I want the user to be prompted a second time only if the username/password is incorrect - not if, say the admin server is down.
I am trying the following piece of code and it is not working as expected (it never enters the first except block). Apparently, my lack of OOPS programming experience is hindering completion of this simple task. Hoping someone can help out with this step.
try:
connect(username, password, 't3://ADMIN_SERVER:ADMIN_PORT')
except SecurityException:
print '\nAuthentication error, add logic to retry\n"
exit(exitcode=1)
except:
print "\n\n ALL OTHER ERRORS \n\n "
(I have also tried NamingException,AuthenticationException in place of SecurityException but it did not help either)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的 except 块对我有用...
您还可以尝试以下方式 NameError 而不是其他试验
try: connect(username, password,
't3://ADMIN_SERVER:ADMIN_PORT')
除了名称错误,e:
print "检查用户名、密码值:", sys.exc_info()[0],
sys.exc_info()[1]
您可以按照自己的方式处理错误e。
Simple except block works for me...
You can also try the following way NameError instead of other trials
try: connect(username, password,
't3://ADMIN_SERVER:ADMIN_PORT')
except NameError, e:
print "Check username, passwd values : ", sys.exc_info()[0],
sys.exc_info()[1]
You can handle error e with your way.