2 回答

TA贡献1801条经验 获得超8个赞
有点晚了,但对于其他任何寻找答案的人来说,JIRA对象的构造函数上有一个max_retries属性。
self.__jira = JIRA( basic_auth=(username, password), max_retries=0, options={ 'server': 'https://jira.dummy.com/' } )
您可以在源代码中看到该变量和其他变量 https://jira.readthedocs.io/en/master/_modules/jira/client.html?highlight=max_retries#

TA贡献2016条经验 获得超9个赞
您似乎希望 在失败时提示用户输入有效的凭据。您不是每次尝试身份验证时都请求凭据,因此请将输入语句移动到无限循环中并尝试以下操作:
while True:
pwd=input("Enter Jira credentials")
try:
jira = JIRA(options={'server': 'https://jira.dummy.com', 'verify': False}, basic_auth=(os.getlogin(), pwd)) //executing this line internally retry the same invalid credential many times
return jira // returns jira handle to another function to process.
except JIRAError as e:
if (e.status_code == 401):
print("Login to JIRA failed. Check your username and password")
pwd = input("Enter your password again to access Jira OR you may close the tool ")
这将要求您再次输入凭据,然后再使用相同的旧内容重试。而且在 try 语句中保留 return 语句后中断是没有意义的。
添加回答
举报