@@ -23,7 +23,7 @@ def __init__(self, message):
23
23
24
24
def unique (seq , keepstr = True ):
25
25
t = type (seq )
26
- if t in ( unicode , str ) :
26
+ if t is str :
27
27
t = (list , t ('' ).join )[bool (keepstr )]
28
28
try :
29
29
remaining = set (seq )
@@ -105,8 +105,18 @@ def _queryTier0DataSvc( self, url ):
105
105
106
106
debug = " -s -S "
107
107
if self ._debug : debug = " -v "
108
-
109
- cmd = '/usr/bin/curl -k -L --user-agent "%s" %s --connect-timeout %i --retry %i %s %s ' % (userAgent , proxy , self ._timeOut , self ._retries , debug , url )
108
+ certs = ""
109
+ if not proxy :
110
+ cert_path = os .getenv ('X509_USER_CERT' , '' )
111
+ if cert_path :
112
+ certs += f' --cert { cert_path } '
113
+ else :
114
+ logging .warn ("No certificate, nor proxy provided for Tier0 access" )
115
+ key_path = os .getenv ('X509_USER_KEY' , '' )
116
+ if key_path :
117
+ certs += f' --key { key_path } '
118
+ cmd = '/usr/bin/curl -k -L --user-agent "%s" %s --connect-timeout %i --retry %i %s %s %s' \
119
+ % (userAgent , proxy , self ._timeOut , self ._retries , debug , url , certs )
110
120
111
121
# time the curl to understand if re-tries have been carried out
112
122
start = time .time ()
@@ -123,7 +133,8 @@ def _queryTier0DataSvc( self, url ):
123
133
logging .error (msg )
124
134
125
135
time .sleep (10 )
126
- cmd = '/usr/bin/curl -k -L --user-agent "%s" %s --connect-timeout %i --retry %i %s %s ' % (userAgent , proxy , self ._timeOut , self ._retries , "-v" , url )
136
+ cmd = '/usr/bin/curl -k -L --user-agent "%s" %s --connect-timeout %i --retry %i %s %s %s ' % \
137
+ (userAgent , proxy , self ._timeOut , self ._retries , "-v" , url , certs )
127
138
process = subprocess .Popen (cmd , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
128
139
(stdoutdata , stderrdata ) = process .communicate ()
129
140
retcode = process .returncode
0 commit comments