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} |
Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 28 | :FOR ${file} IN @{skip_list} |
Joy Onyerikwu | 9b66897 | 2018-05-22 19:10:43 -0500 | [diff] [blame] | 29 | \ ${skip_list_string}= Set Variable ${skip_list_string} && rm ${file} |
Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 30 | |
Joy Onyerikwu | 9b66897 | 2018-05-22 19:10:43 -0500 | [diff] [blame] | 31 | ${file_count1} ${stderr} ${rc}= BMC Execute Command |
| 32 | ... find ${cleanup_dir_path} | wc -l |
| 33 | BMC Execute Command ${skip_list_string} |
Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 34 | |
Joy Onyerikwu | 9b66897 | 2018-05-22 19:10:43 -0500 | [diff] [blame] | 35 | ${file_count2} ${stderrt} ${rc}= BMC Execute Command |
| 36 | ... find ${cleanup_dir_path} | wc -l |
Sunil M | 22d293b | 2017-05-29 05:35:40 -0500 | [diff] [blame] | 37 | Should Be True ${file_count2} < ${file_count1} |
Joy Onyerikwu | 9b66897 | 2018-05-22 19:10:43 -0500 | [diff] [blame] | 38 | # Delete the directory if it is empty. |
| 39 | Run Keyword If ${file_count2} <= 1 |
| 40 | ... BMC Execute Command rm -r ${cleanup_dir_path} |