data_export_7.py 945 B

1234567891011121314151617181920212223242526272829
  1. def generate_csa(result_pk, monitor_pk=None):
  2. result = models.Results.objects.get(pk=result_pk)
  3. report_dir = result.get_report_dir()
  4. raw_data_dir = result.experiment.expDir
  5. try:
  6. monitor = models.FileMonitor.objects.get(pk=monitor_pk)
  7. except models.FileMonitor.DoesNotExist:
  8. monitor = models.FileMonitor()
  9. monitor.tags = "generate_csa"
  10. csa_file_name = "csa_{0:04d}.zip".format(int(result_pk))
  11. monitor.status = "Generating"
  12. monitor.local_dir = report_dir
  13. monitor.name = csa_file_name
  14. monitor.save()
  15. # Generate report PDF file.
  16. # This will create a file named report.pdf in results directory
  17. makePDF.write_report_pdf(result_pk)
  18. csa_path = makeCSA.makeCSA(report_dir, raw_data_dir, monitor.name)
  19. digest_hex, digest_64, size = md5_stats_file(csa_path)
  20. monitor.md5sum = digest_hex
  21. monitor.size = size
  22. monitor.status = "Generated"
  23. monitor.save()