| 73 | return ret, msg |
| 74 | |
| 75 | def _descend(self, dirpath): |
| 76 | ret = True |
| 77 | self.log.dbg(f'recursively uninstall {dirpath}') |
| 78 | for sub in os.listdir(dirpath): |
| 79 | subpath = os.path.join(dirpath, sub) |
| 80 | if os.path.isdir(subpath): |
| 81 | self.log.dbg(f'under {dirpath} uninstall dir {subpath}') |
| 82 | self._descend(subpath) |
| 83 | else: |
| 84 | self.log.dbg(f'under {dirpath} uninstall file {subpath}') |
| 85 | subret, _ = self._remove(subpath) |
| 86 | if not subret: |
| 87 | ret = False |
| 88 | |
| 89 | if dir_empty(dirpath): |
| 90 | # empty |
| 91 | self.log.dbg(f'remove empty dir {dirpath}') |
| 92 | if self.dry: |
| 93 | self.log.dry(f'would \"rm -r {dirpath}\"') |
| 94 | return True, '' |
| 95 | return self._remove_path(dirpath) |
| 96 | self.log.dbg(f'not removing non-empty dir {dirpath}') |
| 97 | return ret, '' |
| 98 | |
| 99 | def _remove_path(self, path): |
| 100 | """remove a file""" |