(self, args)
| 1147 | logger.info('Automatic installation not available on Linux.') |
| 1148 | |
| 1149 | def uninstall_game(self, args): |
| 1150 | if not self.core.lgd.lock_installed(): |
| 1151 | logger.fatal('Failed to acquire installed data lock, only one instance of Legendary may ' |
| 1152 | 'install/import/move applications at a time.') |
| 1153 | return |
| 1154 | |
| 1155 | args.app_name = self._resolve_aliases(args.app_name) |
| 1156 | igame = self.core.get_installed_game(args.app_name) |
| 1157 | if not igame: |
| 1158 | logger.error(f'Game {args.app_name} not installed, cannot uninstall!') |
| 1159 | exit(0) |
| 1160 | |
| 1161 | if not args.yes: |
| 1162 | if not get_boolean_choice(f'Do you wish to uninstall "{igame.title}"?', default=False): |
| 1163 | print('Aborting...') |
| 1164 | exit(0) |
| 1165 | |
| 1166 | if os.name == 'nt' and igame.uninstaller and not args.skip_uninstaller: |
| 1167 | self._handle_uninstaller(igame, args.yes) |
| 1168 | |
| 1169 | try: |
| 1170 | if not igame.is_dlc: |
| 1171 | # Remove DLC first so directory is empty when game uninstall runs |
| 1172 | dlcs = self.core.get_dlc_for_game(igame.app_name) |
| 1173 | for dlc in dlcs: |
| 1174 | if (idlc := self.core.get_installed_game(dlc.app_name)) is not None: |
| 1175 | logger.info(f'Uninstalling DLC "{dlc.app_name}"...') |
| 1176 | self.core.uninstall_game(idlc, delete_files=not args.keep_files) |
| 1177 | |
| 1178 | logger.info(f'Removing "{igame.title}" from "{igame.install_path}"...') |
| 1179 | self.core.uninstall_game(igame, delete_files=not args.keep_files, |
| 1180 | delete_root_directory=not igame.is_dlc) |
| 1181 | logger.info('Game has been uninstalled.') |
| 1182 | except Exception as e: |
| 1183 | logger.warning(f'Removing game failed: {e!r}, please remove {igame.install_path} manually.') |
| 1184 | |
| 1185 | def _handle_uninstaller(self, igame, yes=False): |
| 1186 | uninstaller = igame.uninstaller |
no test coverage detected