Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Resource ../lib/utils.robot |
| 3 | Resource ../lib/connection_client.robot |
| 4 | Resource ../lib/boot_utils.robot |
| 5 | |
| 6 | *** Variables *** |
| 7 | # User defined path to do the cleanup. |
| 8 | ${CLEANUP_DIR_PATH} ${EMPTY} |
| 9 | # List that holds space separated filepaths to skip from cleanup. |
| 10 | ${SKIP_LIST} ${EMPTY} |
| 11 | |
| 12 | *** Keywords *** |
| 13 | |
Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 14 | |
| 15 | Cleanup Dir |
| 16 | [Documentation] Remove leftover files in cleanup directory path. |
| 17 | [Arguments] ${cleanup_dir_path}=${CLEANUP_DIR_PATH} |
| 18 | ... ${skip_list}=${SKIP_LIST} |
| 19 | |
| 20 | # Description of argument(s): |
| 21 | # cleanup_dir_path Directory path to do the cleanup. |
| 22 | # skip_list List of files to skip from cleanup. |
| 23 | |
| 24 | Should Not Be Empty ${cleanup_dir_path} |
| 25 | Should Not Be Empty ${SKIP_LIST} |
Joy Onyerikwu | 9b66897 | 2018-05-22 19:10:43 -0500 | [diff] [blame] | 26 | |
| 27 | ${skip_list_string}= Set Variable cd ${cleanup_dir_path} |
Marissa Garza | 20ccfc7 | 2020-06-19 12:51:10 -0500 | [diff] [blame] | 28 | FOR ${file} IN @{skip_list} |
| 29 | ${skip_list_string}= Set Variable ${skip_list_string} && rm ${file} |
| 30 | END |
Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 31 | |
Joy Onyerikwu | 9b66897 | 2018-05-22 19:10:43 -0500 | [diff] [blame] | 32 | ${file_count1} ${stderr} ${rc}= BMC Execute Command |
| 33 | ... find ${cleanup_dir_path} | wc -l |
| 34 | BMC Execute Command ${skip_list_string} |
Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 35 | |
Joy Onyerikwu | 9b66897 | 2018-05-22 19:10:43 -0500 | [diff] [blame] | 36 | ${file_count2} ${stderrt} ${rc}= BMC Execute Command |
| 37 | ... find ${cleanup_dir_path} | wc -l |
Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 38 | Should Be True ${file_count2} < ${file_count1} |
Joy Onyerikwu | 9b66897 | 2018-05-22 19:10:43 -0500 | [diff] [blame] | 39 | # Delete the directory if it is empty. |
| 40 | Run Keyword If ${file_count2} <= 1 |
| 41 | ... BMC Execute Command rm -r ${cleanup_dir_path} |