Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions channelfinder/ChannelFinderClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from requests import auth
from requests.adapters import HTTPAdapter
from requests.exceptions import HTTPError
import urllib3
from copy import copy

try:
Expand All @@ -28,7 +29,7 @@
__propertiesResource = "/resources/properties"
__tagsResource = "/resources/tags"

def __init__(self, BaseURL=None, username=None, password=None):
def __init__(self, BaseURL=None, username=None, password=None, verify_ssl=True):

Check warning on line 32 in channelfinder/ChannelFinderClient.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter "BaseURL" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=ChannelFinder_pyCFClient&issues=AZ0LzgRAQcX3ClQ7d6Wm&open=AZ0LzgRAQcX3ClQ7d6Wm&pullRequest=40
"""
Channel finder client object. It provides a connection object to perform the following operations:
- find: find all channels satisfying given searching criteria
Expand All @@ -40,15 +41,22 @@
:param username: user name authorized by channel finder service
:param password: password for the authorized user
"""
self.__baseURL = self.__getDefaultConfig("BaseURL", BaseURL)
self.__userName = self.__getDefaultConfig("username", username)
self.__password = self.__getDefaultConfig("password", password)
if self.__userName and self.__password:
self.__auth = auth.HTTPBasicAuth(self.__userName, self.__password)
else:
self.__auth = None
self.__session = requests.Session()
self.__session.mount(self.__baseURL, HTTPAdapter())
try:
self.__baseURL = self.__getDefaultConfig("BaseURL", BaseURL)
self.__userName = self.__getDefaultConfig("username", username)
self.__password = self.__getDefaultConfig("password", password)
self.__verify_ssl = self.__getDefaultConfig("verify_ssl", verify_ssl)
if self.__userName and self.__password:
self.__auth = auth.HTTPBasicAuth(self.__userName, self.__password)
else:
self.__auth = None
self.__session = requests.Session()
self.__session.mount(self.__baseURL, HTTPAdapter())
self.__session.verify = self.__verify_ssl
if not self.__session.verify:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
except Exception as e:
raise RuntimeError("Error creating ChannelFinderClient: " + str(e))

def __getDefaultConfig(self, key, ref):
"""
Expand Down
Loading