mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-27 23:16:14 +01:00
Merge pull request #1125 from dmach/bugfixes
Fix connection to work on python 3.6 & other bugfixes
This commit is contained in:
commit
09731132fb
@ -296,8 +296,9 @@ def http_request(method, url, headers=None, data=None, file=None):
|
|||||||
if not isinstance(e.reason, urllib3.exceptions.SSLError):
|
if not isinstance(e.reason, urllib3.exceptions.SSLError):
|
||||||
# re-raise exceptions that are not related to SSL
|
# re-raise exceptions that are not related to SSL
|
||||||
raise
|
raise
|
||||||
|
# ssl.SSLCertVerificationError doesn't exist on python 3.6
|
||||||
if isinstance(e.reason.args[0], ssl.SSLCertVerificationError):
|
# ssl.CertificateError is an alias for ssl.SSLCertVerificationError on python 3.7+
|
||||||
|
if isinstance(e.reason.args[0], ssl.CertificateError):
|
||||||
self_signed_verify_codes = (
|
self_signed_verify_codes = (
|
||||||
oscssl.X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT,
|
oscssl.X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT,
|
||||||
oscssl.X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN,
|
oscssl.X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN,
|
||||||
|
@ -3327,7 +3327,7 @@ def makeurl(baseurl, l, query=[]):
|
|||||||
function. In case of a list not -- this is to be backwards compatible.
|
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)
|
print('makeurl:', baseurl, l, query)
|
||||||
|
|
||||||
if isinstance(query, type(list())):
|
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_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)
|
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)
|
print('[ %s ]' % xpath)
|
||||||
res = search(apiurl, request=xpath)
|
res = search(apiurl, request=xpath)
|
||||||
collection = res['request']
|
collection = res['request']
|
||||||
@ -4414,7 +4414,7 @@ def get_exact_request_list(apiurl, src_project, dst_project, src_package=None, d
|
|||||||
if req_type:
|
if req_type:
|
||||||
xpath += " and action/@type=\'%s\'" % req_type
|
xpath += " and action/@type=\'%s\'" % req_type
|
||||||
|
|
||||||
if conf.config['verbose']:
|
if conf.config['debug']:
|
||||||
print('[ %s ]' % xpath)
|
print('[ %s ]' % xpath)
|
||||||
|
|
||||||
res = search(apiurl, request=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:
|
for i in exclude_target_projects:
|
||||||
xpath = xpath_join(xpath, '(not(action/target/@project=\'%(prj)s\'))' % {'prj': i}, op='and')
|
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)
|
print('[ %s ]' % xpath)
|
||||||
queries = {}
|
queries = {}
|
||||||
if withfullhistory:
|
if withfullhistory:
|
||||||
|
@ -52,10 +52,15 @@ class TrustedCertStore:
|
|||||||
if not self.host:
|
if not self.host:
|
||||||
raise ValueError("Empty `host`")
|
raise ValueError("Empty `host`")
|
||||||
|
|
||||||
file_name = f"{self.host}_{self.port}"
|
|
||||||
self.dir_path = os.path.expanduser("~/.config/osc/trusted-certs")
|
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):
|
if os.path.isfile(self.pem_path):
|
||||||
# load permanently trusted certificate that is stored on disk
|
# load permanently trusted certificate that is stored on disk
|
||||||
with open(self.pem_path, "rb") as f:
|
with open(self.pem_path, "rb") as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user