Backups.py 1.1 KB

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