@@ -186,41 +186,41 @@ def main():
186186
187187 if not client_id :
188188 module .fail_json (msg = str ("Client ID not specified and unable to determine Client ID "
189- f "from '{ REDHAT_PRODUCT_DOWNLOAD_CLIENT_ID_ENV_VAR } ' environment variable." ))
189+ "from '{0 }' environment variable." . format ( REDHAT_PRODUCT_DOWNLOAD_CLIENT_ID_ENV_VAR ) ))
190190
191191 if not client_secret :
192192 client_secret = os .environ .get (REDHAT_PRODUCT_DOWNLOAD_CLIENT_SECRET_ENV_VAR )
193193
194194 if not client_secret :
195195 module .fail_json (msg = str ("Client Secret not specified and unable to determine Client Secret "
196- f "from '{ REDHAT_PRODUCT_DOWNLOAD_CLIENT_SECRET_ENV_VAR } ' environment variable." ))
196+ "from '{0 }' environment variable." . format ( REDHAT_PRODUCT_DOWNLOAD_CLIENT_SECRET_ENV_VAR ) ))
197197
198198 if not dest :
199199 module .fail_json (msg = str ("Destination path not provided" ))
200200
201201 session = get_authenticated_session (module , sso_url , validate_certs , client_id , client_secret )
202202
203- api_base_url = f" { api_url } { API_SERVICE_PATH } "
203+ api_base_url = "{0}{1}" . format ( api_url , API_SERVICE_PATH )
204204
205205 if product_category is not None :
206206 # List Product Categories
207207 product_categories = []
208208
209209 try :
210- product_categories = perform_search (session , f" { api_base_url } { LIST_PRODUCT_CATEGORIES_ENDPOINT } " , validate_certs )
210+ product_categories = perform_search (session , "{0}{1}" . format ( api_base_url , LIST_PRODUCT_CATEGORIES_ENDPOINT ) , validate_certs )
211211 except Exception as err :
212212 module .fail_json (msg = "Error Listing Available Product Categories: %s" % (to_native (err )))
213213
214214 if product_category not in product_categories :
215- module .fail_json (msg = f "'{ product_category } ' is not a valid Product Category" )
215+ module .fail_json (msg = "'{0 }' is not a valid Product Category" . format ( product_category ) )
216216
217217 # Search for Products
218218 search_results = []
219219
220220 search_params = generate_search_params (product_category , product_id , product_type , product_version )
221221
222222 try :
223- search_results = perform_search (session , f" { api_base_url } { SEARCH_ENDPOINT } " , validate_certs , search_params )
223+ search_results = perform_search (session , "{0}{1}" . format ( api_base_url , SEARCH_ENDPOINT ) , validate_certs , search_params )
224224 except Exception as err :
225225 module .fail_json (msg = "Error Searching for Products: %s" % (to_native (err )))
226226
@@ -229,11 +229,11 @@ def main():
229229 # Print error with results if more than 1 exists
230230 if products_found != 1 :
231231 msg = [
232- (f "Error: Unable to locate a single product to download. '{ products_found } ' products found." )
232+ ("Error: Unable to locate a single product to download. '{0 }' products found." . format ( products_found ) )
233233 ]
234234
235235 for productIdx , product in enumerate (search_results ):
236- msg .append (f" { productIdx + 1 } - ({ product ['id' ]} ) { product ['title' ]} ." )
236+ msg .append ("{0 } - ({1}) {2}." . format ( productIdx + 1 , product ['id' ], product ['title' ]) )
237237
238238 module .fail_json (msg = " " .join (msg ))
239239
@@ -250,7 +250,7 @@ def main():
250250 )
251251
252252 if os .path .exists (dest ) and not force :
253- file_args = module .load_file_common_arguments (module .params , path = dest )
253+ file_args = module .load_file_common_arguments (module .params )
254254 result ['changed' ] = module .set_fs_attributes_if_different (file_args , False )
255255
256256 if result ['changed' ]:
@@ -272,20 +272,20 @@ def main():
272272 module .fail_json (msg = "Destination %s is not writable" % (os .path .dirname (dest )), ** result )
273273
274274 try :
275- with session .get (search_results [0 ]["download_path" ], follow_redirects = True , headers = {"User-Agent" : "product_download" }) as r :
276- chunk_size = 8192
277- with open (dest , 'wb' ) as f :
278- while True :
279- chunk = r .read (chunk_size )
280- if not chunk :
281- break
282- f .write (chunk )
275+ r = session .get (search_results [0 ]["download_path" ], follow_redirects = True , headers = {"User-Agent" : "product_download" })
276+ chunk_size = 8192
277+ with open (dest , 'wb' ) as f :
278+ while True :
279+ chunk = r .read (chunk_size )
280+ if not chunk :
281+ break
282+ f .write (chunk )
283283
284284 result ['changed' ] = True
285285 except Exception as err :
286286 module .fail_json (msg = "Error Downloading %s: %s" % (search_results [0 ]['title' ], to_native (err )))
287287
288- file_args = module .load_file_common_arguments (module .params , path = dest )
288+ file_args = module .load_file_common_arguments (module .params )
289289 result ['changed' ] = module .set_fs_attributes_if_different (file_args , result ['changed' ])
290290
291291 try :
0 commit comments