mateusz-szczesny opened a new pull request #111:
URL: https://github.com/apache/ranger/pull/111


   Working on windows produces bug when given Ranger URL has not leading slash 
which is not common behavior in base URL structure.
   
   ```python
   from apache_ranger.client.ranger_client import RangerService, RangerClient
   
   ranger_url = "http://dummy.hostname.com:6080";
   ranger_auth = ("dummy.username", "dummy.password")
   ranger = RangerClient(ranger_url, ranger_auth)
   
   for role in ranger.find_roles():
       print(str(role.id))
   ```
   Above code leads to such error on Windows like systems.
   ```
   Traceback (most recent call last):
     File "C:\Users\szczesny\Desktop\cdpctl\main.py", line 8, in <module>
       for role in ranger.find_roles():
     File 
"C:\Users\szczesny\AppData\Local\pypoetry\Cache\virtualenvs\cdpctl-1KAmzwEP-py3.9\lib\site-packages\apache_ranger\client\ranger_client.py",
 line 327, in find_roles
       resp = self.__call_api(RangerClient.FIND_ROLES, filter)
     File 
"C:\Users\szczesny\AppData\Local\pypoetry\Cache\virtualenvs\cdpctl-1KAmzwEP-py3.9\lib\site-packages\apache_ranger\client\ranger_client.py",
 line 427, in __call_api
       raise RangerServiceException(api, response)
     File 
"C:\Users\szczesny\AppData\Local\pypoetry\Cache\virtualenvs\cdpctl-1KAmzwEP-py3.9\lib\site-packages\apache_ranger\exceptions.py",
 line 39, in __init__
       respJson = response.json()
     File 
"C:\Users\szczesny\AppData\Local\pypoetry\Cache\virtualenvs\cdpctl-1KAmzwEP-py3.9\lib\site-packages\requests\models.py",
 line 910, in json
       return complexjson.loads(self.text, **kwargs)
     File 
"C:\Users\szczesny\AppData\Local\Programs\Python\Python39\lib\json\__init__.py",
 line 346, in loads
       return _default_decoder.decode(s)
     File 
"C:\Users\szczesny\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", 
line 337, in decode
       obj, end = self.raw_decode(s, idx=_w(s, 0).end())
     File 
"C:\Users\szczesny\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", 
line 355, in raw_decode
       raise JSONDecodeError("Expecting value", s, err.value) from None
   json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
   ```
   
   It can be fixed by manually adding leading slash, but it is just an ugly 
workaround and may lead to problem when hostname along with port will come from 
env vars.
   
   ```python
   [...]
   ranger_url = "http://dummy.hostname.com:6080/";
   [...]
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to