Backups.py 1.2 KB

1234567891011121314151617181920212223242526272829303132
  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. class Backups:
  5. """
  6. The backups API provides a version-proof bridge between Cura's BackupManager and plugins that hook into it.
  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. """
  13. manager = BackupsManager() # Re-used instance of the backups manager.
  14. def createBackup(self) -> (bytes, dict):
  15. """
  16. Create a new backup using the BackupsManager.
  17. :return: Tuple containing a ZIP file with the backup data and a dict with meta data about the backup.
  18. """
  19. return self.manager.createBackup()
  20. def restoreBackup(self, zip_file: bytes, meta_data: dict) -> None:
  21. """
  22. Restore a backup using the BackupManager.
  23. :param zip_file: A ZIP file containing the actual backup data.
  24. :param meta_data: Some meta data needed for restoring a backup, like the Cura version number.
  25. """
  26. return self.manager.restoreBackup(zip_file, meta_data)