wlst 身份验证异常再次提示用户

发布于 2024-10-27 14:36:37 字数 679 浏览 2 评论 0原文

我编写了几个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜妞爱困 2024-11-03 14:36:37

简单的 except 块对我有用...

您还可以尝试以下方式 NameError 而不是其他试验

  1. 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

  1. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文