Backups.py 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import Tuple, Optional
  4. from cura.Backups.BackupsManager import BackupsManager
  5. ## The back-ups API provides a version-proof bridge between Cura's
  6. # BackupManager and plug-ins that hook into it.
  7. #
  8. # Usage:
  9. # ``from cura.API import CuraAPI
  10. # api = CuraAPI()
  11. # api.backups.createBackup()
  12. # api.backups.restoreBackup(my_zip_file, {"cura_release": "3.1"})``
  13. class Backups:
  14. manager = BackupsManager() # Re-used instance of the backups manager.
  15. ## Create a new back-up using the BackupsManager.
  16. # \return Tuple containing a ZIP file with the back-up data and a dict
  17. # with metadata about the back-up.
  18. def createBackup(self) -> Tuple[Optional[bytes], Optional[dict]]:
  19. return self.manager.createBackup()
  20. ## Restore a back-up using the BackupsManager.
  21. # \param zip_file A ZIP file containing the actual back-up data.
  22. # \param meta_data Some metadata needed for restoring a back-up, like the
  23. # Cura version number.
  24. def restoreBackup(self, zip_file: bytes, meta_data: dict) -> None:
  25. return self.manager.restoreBackup(zip_file, meta_data)