diff --git a/osc/connection.py b/osc/connection.py index 8353544b..5b6f8aba 100644 --- a/osc/connection.py +++ b/osc/connection.py @@ -296,8 +296,9 @@ def http_request(method, url, headers=None, data=None, file=None): if not isinstance(e.reason, urllib3.exceptions.SSLError): # re-raise exceptions that are not related to SSL raise - - if isinstance(e.reason.args[0], ssl.SSLCertVerificationError): + # ssl.SSLCertVerificationError doesn't exist on python 3.6 + # ssl.CertificateError is an alias for ssl.SSLCertVerificationError on python 3.7+ + if isinstance(e.reason.args[0], ssl.CertificateError): self_signed_verify_codes = ( oscssl.X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, oscssl.X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN, diff --git a/osc/core.py b/osc/core.py index abbd788e..0fae029b 100644 --- a/osc/core.py +++ b/osc/core.py @@ -3327,7 +3327,7 @@ def makeurl(baseurl, l, query=[]): function. In case of a list not -- this is to be backwards compatible. """ - if conf.config['verbose']: + if conf.config['debug']: print('makeurl:', baseurl, l, query) if isinstance(query, type(list())): @@ -4362,7 +4362,7 @@ def get_review_list(apiurl, project='', package='', byuser='', bygroup='', bypro xpath_base = xpath_join(xpath_base, 'action/source/@%(kind)s=\'%(val)s\'', op='or', inner=True) xpath = xpath_join(xpath, xpath_base % {'kind': kind, 'val': val}, op='and', nexpr_parentheses=True) - if conf.config['verbose']: + if conf.config['debug']: print('[ %s ]' % xpath) res = search(apiurl, request=xpath) collection = res['request'] @@ -4414,7 +4414,7 @@ def get_exact_request_list(apiurl, src_project, dst_project, src_package=None, d if req_type: xpath += " and action/@type=\'%s\'" % req_type - if conf.config['verbose']: + if conf.config['debug']: print('[ %s ]' % xpath) res = search(apiurl, request=xpath) @@ -4453,7 +4453,7 @@ def get_request_list(apiurl, project='', package='', req_who='', req_state=('new for i in exclude_target_projects: xpath = xpath_join(xpath, '(not(action/target/@project=\'%(prj)s\'))' % {'prj': i}, op='and') - if conf.config['verbose']: + if conf.config['debug']: print('[ %s ]' % xpath) queries = {} if withfullhistory: diff --git a/osc/oscssl.py b/osc/oscssl.py index b130c5ec..2e6b7ea0 100644 --- a/osc/oscssl.py +++ b/osc/oscssl.py @@ -52,10 +52,15 @@ class TrustedCertStore: if not self.host: raise ValueError("Empty `host`") - file_name = f"{self.host}_{self.port}" self.dir_path = os.path.expanduser("~/.config/osc/trusted-certs") - self.pem_path = os.path.join(self.dir_path, f"{file_name}.pem") + if not os.path.isdir(self.dir_path): + try: + os.makedirs(self.dir_path, mode=0o700) + except FileExistsError: + pass + file_name = f"{self.host}_{self.port}" + self.pem_path = os.path.join(self.dir_path, f"{file_name}.pem") if os.path.isfile(self.pem_path): # load permanently trusted certificate that is stored on disk with open(self.pem_path, "rb") as f: