File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -203,18 +203,17 @@ def get_capabilities(self) -> requests.Response:
203203 # checking if the services is under basic auth
204204 # getting the service
205205 from geonode .services .models import Service
206+
206207 # check if the connected service has username and password
207208 has_basic_auth = Service .objects .filter (
208- harvester__pk = self .harvester_id ,
209- username__isnull = False ,
210- password__isnull = False
209+ harvester__pk = self .harvester_id , username__isnull = False , password__isnull = False
211210 )
212211 basic_auth = None
213212 if has_basic_auth .exists ():
214213 # if the username and password are set, we can prepare the basic auth for the request
215214 service = has_basic_auth .first ()
216215 basic_auth = HTTPBasicAuth (service .username , service .get_password ())
217-
216+
218217 get_capabilities_response = self .http_session .get (
219218 self .get_ogc_wms_url (wms_url , version = _version ), params = params , auth = basic_auth
220219 )
Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ def create_thumbnail(
158158 styles = styles ,
159159 width = width ,
160160 height = height ,
161- instance = instance
161+ instance = instance ,
162162 )
163163 )
164164 except Exception as e :
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ def get_map(
144144 height : int = 200 ,
145145 max_retries : int = 3 ,
146146 retry_delay : int = 1 ,
147- instance = None
147+ instance = None ,
148148):
149149 """
150150 Function fetching an image from OGC server.
@@ -201,12 +201,15 @@ def get_map(
201201 else :
202202 headers ["Authorization" ] = f"Bearer { additional_kwargs ['access_token' ]} "
203203
204- if instance and instance .subtype == ' remote' and instance .remote_typename :
204+ if instance and instance .subtype == " remote" and instance .remote_typename :
205205 from geonode .services .models import Service
206+
206207 service = Service .objects .filter (name = instance .remote_typename , username__isnull = False , password__isnull = False )
207208 if service .exists ():
208209 service = service .first ()
209- encoded_credentials = base64 .b64encode (f"{ service .username } :{ service .get_password ()} " .encode ("UTF-8" )).decode ("ascii" )
210+ encoded_credentials = base64 .b64encode (
211+ f"{ service .username } :{ service .get_password ()} " .encode ("UTF-8" )
212+ ).decode ("ascii" )
210213 headers ["Authorization" ] = f"Basic { encoded_credentials } "
211214
212215 image = None
You can’t perform that action at this time.
0 commit comments