(self, params, **kwargs)
| 2244 | |
| 2245 | class DeleteCorruptedCommand(Command): |
| 2246 | def execute(self, params, **kwargs): |
| 2247 | bad_records = set() |
| 2248 | for record_uid in params.record_cache: |
| 2249 | record = params.record_cache[record_uid] |
| 2250 | if not record.get('data_unencrypted'): |
| 2251 | if record_uid in params.record_owner_cache: |
| 2252 | own = params.record_owner_cache[record_uid] |
| 2253 | if own.owner is True: |
| 2254 | bad_records.add(record_uid) |
| 2255 | if len(bad_records) > 0: |
| 2256 | uc = user_choice('Do you want to delete {0} corrupted records?'.format(len(bad_records)), 'yn', default='n') |
| 2257 | if uc.lower() == 'y': |
| 2258 | request = { |
| 2259 | 'command': 'record_update', |
| 2260 | 'delete_records': list(bad_records) |
| 2261 | } |
| 2262 | logging.info('Deleting %s records from Keeper', len(params.record_cache)) |
| 2263 | response_json = api.communicate(params, request) |
| 2264 | success = [info for info in response_json['delete_records'] if info['status'] == 'success'] |
| 2265 | if len(success) > 0: |
| 2266 | logging.info("%s records deleted successfully", len(success)) |
| 2267 | failures = [info for info in response_json['delete_records'] if info['status'] != 'success'] |
| 2268 | if len(failures) > 0: |
| 2269 | logging.warning("%s records failed to delete", len(failures)) |
| 2270 | else: |
| 2271 | logging.info('No corrupted records are found.') |
| 2272 | |
| 2273 | |
| 2274 | class GenerateCommand(Command): |
nothing calls this directly
no test coverage detected