UploadMaterialsJob.py 865 B

12345678910111213141516171819202122232425
  1. # Copyright (c) 2021 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from PyQt5.QtCore import QUrl
  4. import os # To delete the archive when we're done.
  5. import tempfile # To create an archive before we upload it.
  6. import cura.CuraApplication # Imported like this to prevent circular imports.
  7. from UM.Job import Job
  8. class UploadMaterialsJob(Job):
  9. """
  10. Job that uploads a set of materials to the Digital Factory.
  11. """
  12. def run(self):
  13. archive_file = tempfile.NamedTemporaryFile("wb", delete = False)
  14. archive_file.close()
  15. cura.CuraApplication.CuraApplication.getInstance().getMaterialManagementModel().exportAll(QUrl.fromLocalFile(archive_file.name))
  16. print("Creating archive completed. Now we need to upload it.") # TODO: Upload that file.
  17. os.remove(archive_file.name) # Clean up.