david-caro / python-foreman

Small low level python wrapper around Foreman API
GNU General Public License v2.0
57 stars 37 forks source link

fix getting version from home page with bad HTTP headers #21

Closed machalekj closed 8 years ago

machalekj commented 9 years ago

This small change fixes get_foreman_version method by not getting home page with session, which has HTTP headers for accepting just JSON, but instead with requests.get method. This fixed our issue with Foreman class initialization.

david-caro commented 9 years ago

Thanks for the fix!

I'll test it on our servers too, do you remember the details of the error you were getting?

machalekj commented 9 years ago

Hi, before my patching initialization of foreman.client.Foreman object failed with following traceback:

from foreman.client import Foreman f = Foreman('https://localhost', ('myuser', 'mypass')) ... Traceback (most recent call last): File "", line 1, in File "foreman/client.py", line 347, in init self.version = self.get_foreman_version() File "foreman/client.py", line 369, in get_foreman_version raise ForemanException(res, 'Something went wrong') foreman.client.ForemanException: Something went wrong

I am using Foreman v1.5.3.

david-caro commented 8 years ago

Sorry about the delay