48
48
- Download filename of the SAP software.
49
49
required: false
50
50
type: str
51
- download_path :
51
+ dest :
52
52
description:
53
53
- Destination folder path.
54
54
required: true
80
80
suser_password: 'password'
81
81
search_query:
82
82
- 'SAPCAR_1324-80000936.EXE'
83
- download_path : "/tmp/"
83
+ dest : "/tmp/"
84
84
- name: Download using direct link and filename
85
85
community.sap_launchpad.software_center_download:
86
86
suser_id: 'SXXXXXXXX'
87
87
suser_password: 'password'
88
88
download_link: 'https://softwaredownloads.sap.com/file/0010000000048502015'
89
89
download_filename: 'IW_FNDGC100.SAR'
90
- download_path : "/tmp/"
90
+ dest : "/tmp/"
91
91
'''
92
92
93
93
RETURN = r'''
116
116
from ..module_utils .sap_launchpad_software_center_download_runner import *
117
117
from ..module_utils .sap_id_sso import sap_sso_login
118
118
119
- def _check_similar_files (download_path , filename ):
119
+ def _check_similar_files (dest , filename ):
120
120
"""
121
121
Checks for similar files in the download path based on the given filename.
122
122
123
123
Args:
124
- download_path (str): The path where files are downloaded.
124
+ dest (str): The path where files are downloaded.
125
125
filename (str): The filename to check for similar files.
126
126
127
127
Returns:
128
128
bool: True if similar files exist, False otherwise.
129
129
filename_similar_names: A list of similar filenames if they exist, empty list otherwise.
130
130
"""
131
- # pattern = download_path + '/**/' + os.path.splitext(filename)[0]
131
+ # pattern = dest + '/**/' + os.path.splitext(filename)[0]
132
132
filename_base = os .path .splitext (filename )[0 ]
133
- filename_pattern = os .path .join (download_path , "**" , filename_base )
133
+ filename_pattern = os .path .join (dest , "**" , filename_base )
134
134
filename_similar = glob .glob (filename_pattern , recursive = True )
135
135
136
136
if filename_similar :
@@ -150,7 +150,7 @@ def run_module():
150
150
search_query = dict (type = 'str' , required = False , default = '' ),
151
151
download_link = dict (type = 'str' , required = False , default = '' ),
152
152
download_filename = dict (type = 'str' , required = False , default = '' ),
153
- download_path = dict (type = 'str' , required = True ),
153
+ dest = dict (type = 'str' , required = True ),
154
154
dry_run = dict (type = 'bool' , required = False , default = False ),
155
155
deduplicate = dict (type = 'str' , required = False , default = '' ),
156
156
search_alternatives = dict (type = 'bool' , required = False , default = False )
@@ -174,7 +174,7 @@ def run_module():
174
174
else :
175
175
query = None
176
176
177
- download_path = module .params ['download_path ' ]
177
+ dest = module .params ['dest ' ]
178
178
download_link = module .params .get ('download_link' )
179
179
download_filename = module .params .get ('download_filename' )
180
180
dry_run = module .params .get ('dry_run' )
@@ -207,7 +207,7 @@ def run_module():
207
207
208
208
# Search for existing files using exact filename
209
209
filename = query if query else download_filename
210
- filename_exact = os .path .join (download_path , filename )
210
+ filename_exact = os .path .join (dest , filename )
211
211
result ['filename' ] = filename
212
212
213
213
if os .path .exists (filename_exact ):
@@ -216,7 +216,7 @@ def run_module():
216
216
module .exit_json (** result )
217
217
else :
218
218
# Exact file not found, search for similar files with pattern
219
- filename_similar_exists , filename_similar_names = _check_similar_files (download_path , filename )
219
+ filename_similar_exists , filename_similar_names = _check_similar_files (dest , filename )
220
220
if filename_similar_exists and not (query and search_alternatives ):
221
221
result ['skipped' ] = True
222
222
result ['msg' ] = f"Similar file(s) already exist: { ', ' .join (filename_similar_names )} "
@@ -235,14 +235,14 @@ def run_module():
235
235
result ['filename' ] = download_filename
236
236
result ['alternative' ] = True
237
237
238
- filename_alternative_exact = os .path .join (download_path , download_filename )
238
+ filename_alternative_exact = os .path .join (dest , download_filename )
239
239
if os .path .exists (filename_alternative_exact ):
240
240
result ['skipped' ] = True
241
241
result ['msg' ] = f"Alternative file already exists: { download_filename } - original file { query } is not available to download"
242
242
module .exit_json (** result )
243
243
else :
244
244
# Exact file not found, search for similar files with pattern
245
- filename_similar_exists , filename_similar_names = _check_similar_files (download_path , download_filename )
245
+ filename_similar_exists , filename_similar_names = _check_similar_files (dest , download_filename )
246
246
if filename_similar_exists :
247
247
result ['skipped' ] = True
248
248
result ['msg' ] = f"Similar alternative file(s) already exist: { ', ' .join (filename_similar_names )} "
@@ -252,13 +252,13 @@ def run_module():
252
252
elif filename != download_filename and not alternative_found :
253
253
result ['filename' ] = download_filename
254
254
255
- if os .path .exists (os .path .join (download_path , download_filename )):
255
+ if os .path .exists (os .path .join (dest , download_filename )):
256
256
result ['skipped' ] = True
257
257
result ['msg' ] = f"File already exists with correct name: { download_filename } "
258
258
module .exit_json (** result )
259
259
else :
260
260
# Exact file not found, search for similar files with pattern
261
- filename_similar_exists , filename_similar_names = _check_similar_files (download_path , download_filename )
261
+ filename_similar_exists , filename_similar_names = _check_similar_files (dest , download_filename )
262
262
if filename_similar_exists :
263
263
result ['skipped' ] = True
264
264
result ['msg' ] = f"Similar file(s) already exist for correct name { download_filename } : { ', ' .join (filename_similar_names )} "
@@ -281,7 +281,7 @@ def run_module():
281
281
else :
282
282
module .fail_json (msg = "Download link {} is not available" .format (download_link ))
283
283
284
- download_software (download_link , download_filename , download_path )
284
+ download_software (download_link , download_filename , dest )
285
285
286
286
# Update final results json
287
287
result ['changed' ] = True
0 commit comments