22
33from __future__ import absolute_import , division , print_function
44
5+ import os
56import re
6- from base64 import b16decode
7- from subprocess import PIPE , Popen
87import ssl
98import sys
10- import os
9+ from base64 import b16decode
10+ from subprocess import PIPE , Popen
1111
1212try :
1313 IsADirectoryError # pylint: disable=used-before-assignment
@@ -47,15 +47,10 @@ def findExtension(oid, lines):
4747def getVO (proxy_data ):
4848 """Fetches the VO in a chain certificate
4949
50- Args:
51- proxy_data (bytes): Bytes for the proxy chain
52-
53- Raises:
54- Exception: Any error related to openssl
55- NotImplementedError: Not documented error
56-
57- Returns:
58- str: A VO
50+ :param proxy_data: Bytes for the proxy chain
51+ :type proxy_data: bytes
52+ :return: A VO
53+ :rtype: str
5954 """
6055
6156 chain = re .findall (br"-----BEGIN CERTIFICATE-----\n.+?\n-----END CERTIFICATE-----" , proxy_data , flags = re .DOTALL )
@@ -100,11 +95,11 @@ def __init__(self, url, caPath, name="unknown"):
10095 def generateUserAgent (self , pilotUUID ):
10196 """To analyse the traffic, we can send a taylor-made User-Agent
10297
103- Args:
104- pilotUUID (str): Unique ID of the Pilot
105-
106- Returns:
107- str: The generated user agent
98+ :param pilotUUID: Unique ID of the Pilot
99+ :type pilotUUID: str
100+ :type param_name: param_type
101+ :return: The generated user agent
102+ :rtype: str
108103 """
109104 return "Dirac Pilot [%s]" % pilotUUID
110105
@@ -117,12 +112,12 @@ def _prepareRequest(self):
117112 def executeRequest (self , raw_data , headers = {"User-Agent" : "Dirac Pilot [Unknown ID]" }):
118113 """Execute a HTTP request with the data, headers, and the pre-defined data (SSL + auth)
119114
120- Args:
121- raw_data (dict): Data to send
122- headers (dict, optional) : Headers to send, helps to track requests. Defaults to {"User-Agent": "Dirac Pilot [Unknown ID]"}.
123-
124- Returns:
125- str: Response of the HTTP request
115+ :param raw_data: Data to send
116+ :type raw_data: dict
117+ :param headers: Headers to send, helps to track requests. Defaults to {"User-Agent": "Dirac Pilot [Unknown ID]"}.
118+ :type headers: dict, optional
119+ :return: Response of the HTTP request
120+ :rtype: str
126121 """
127122 if sys .version_info [0 ] == 3 :
128123 data = urlencode (raw_data ).encode ("utf-8" ) # encode to bytes ! for python3
@@ -148,7 +143,7 @@ def __init__(self, url, caPath, jwtData):
148143
149144 def executeRequest (self , raw_data , headers = {"User-Agent" : "Dirac Pilot [Unknown ID]" }):
150145 # Adds the JWT in the HTTP request (in the Bearer field)
151- headers ["Bearer " ] = self .jwtData
146+ headers ["Authorization " ] = "Bearer: %s" % self .jwtData
152147 return super (TokenBasedRequest , self ).executeRequest (raw_data , headers )
153148
154149
0 commit comments