jesper-raemaekers / python-polarion

A Python package to access the Polarion WSDL API.
MIT License
57 stars 35 forks source link

python-polarion Could not find project in Python 3.11.1 #149

Closed JiangChangda closed 11 months ago

JiangChangda commented 1 year ago

Hello Thank you for the library, it's very good.

But during the use process, I encountered a problem: The probability of successfully accessing the polarion project using Python 3.11.1 is very low. Using Python 3.11.6/3.12.0 almost guarantees that Project can be obtained every time. Could you please help me take a look at this issue? Here is my test code: os.environ['SSL_CERT_FILE'] = certifi.where() url = 'https://xxxx.com/polarion'

username = input("Please enter username: ")

#password = input("Please enter password: ")
user = "UserName"
password = "Password"
client = Polarion(url, user, password, verify_certificate=True)
projetId = 'XXXX'
project = client.getProject(projetId)
tamtam1111 commented 1 year ago

Hi, i have the same problem, but regardless of the version I am using. In desperation, I implemented a very slow and ugly workaround because I found that the connection continues to work after retrieving an item. I don't know if this is a bug or due to our company's infrastructure.

def login(user:str, pw:str) ->polarion.Polarion:
    client = polarion.Polarion("https://polarion.domain.com/polarion", user, pw,  proxy="http://proxy.domain.com:8080",  verify_certificate=True)
    return client

def try_to_work(user, pw):
    for i in range(50):

        try:
            client = login(user, pw)
            project = client.getProject("Project_ID")

            workitem = project.getWorkitem("idxyz")
            print("connected")
            return client
        except Exception as e:
            print(e)
            print("retry")
    raise ConnectionError("No connection possible")`
tamtam1111 commented 1 year ago

I have managed to get it to work. After some research it seems to be a bug with the soap client and tls. Disabling session validation works for me.

from requests import Session
from polarion import polarion
from requests.auth import HTTPBasicAuth

def login(user:str, pw:str) ->polarion.Polarion:
    session = Session()
    session.auth = HTTPBasicAuth(user, pw)
    session.verify = False

    client = polarion.Polarion('url', user, pw,  proxy='url', request_session=session, verify_certificate=True)
    return client
jesper-raemaekers commented 11 months ago

That is interesting. I'll include this in the documentation.