async def delete_repo(self, name: str) -> None: """Delete a repository and its folders. Parameters ---------- name : str The name of the repository to delete. Raises ------ .MissingGitRepo If the repo does not exist. """ repo = self.get_repo(name) if repo is None: raise errors.MissingGitRepo( f"There is no repo with the name {name}") safe_delete(repo.folder_path) await self.config.repos.clear_raw(repo.name) try: del self._repos[name] except KeyError: pass
async def remove_instance( instance: str, interactive: bool = False, delete_data: Optional[bool] = None, _create_backup: Optional[bool] = None, drop_db: Optional[bool] = None, remove_datapath: Optional[bool] = None, ) -> None: data_manager.load_basic_configuration(instance) backend = get_current_backend(instance) if interactive is True and delete_data is None: msg = "Would you like to delete this instance's data?" if backend != BackendType.JSON: msg += " The database server must be running for this to work." delete_data = click.confirm(msg, default=False) if interactive is True and _create_backup is None: msg = "Would you like to make a backup of the data for this instance?" if backend != BackendType.JSON: msg += " The database server must be running for this to work." _create_backup = click.confirm(msg, default=False) if _create_backup is True: await create_backup(instance) driver_cls = drivers.get_driver_class(backend) if delete_data is True: await driver_cls.initialize(**data_manager.storage_details()) try: await driver_cls.delete_all_data(interactive=interactive, drop_db=drop_db) finally: await driver_cls.teardown() if interactive is True and remove_datapath is None: remove_datapath = click.confirm( "Would you like to delete the instance's entire datapath?", default=False) if remove_datapath is True: data_path = data_manager.core_data_path().parent safe_delete(data_path) save_config(instance, {}, remove=True) print("The instance {} has been removed.".format(instance))
async def remove_instance( instance, interactive: bool = False, delete_data: Optional[bool] = None, _create_backup: Optional[bool] = None, drop_db: Optional[bool] = None, remove_datapath: Optional[bool] = None, ): data_manager.load_basic_configuration(instance) if interactive is True and delete_data is None: delete_data = click.confirm( "Would you like to delete this instance's data?", default=False ) if interactive is True and _create_backup is None: _create_backup = click.confirm( "Would you like to make a backup of the data for this instance?", default=False ) if _create_backup is True: await create_backup(instance) backend = get_current_backend(instance) driver_cls = drivers.get_driver_class(backend) if delete_data is True: await driver_cls.delete_all_data(interactive=interactive, drop_db=drop_db) if interactive is True and remove_datapath is None: remove_datapath = click.confirm( "Would you like to delete the instance's entire datapath?", default=False ) if remove_datapath is True: data_path = data_manager.core_data_path().parent safe_delete(data_path) save_config(instance, {}, remove=True) print("The instance {} has been removed\n".format(instance))