Esempio n. 1
0
    archive_file_name = ""
    try:
        # Create the actual archive file.
        # TODO: Create it in galah's /var/ directory
        archive_fd, archive_file_name = tempfile.mkstemp(suffix = ".zip")

        # Close the file because we won't actually do any writing to it,
        # rather tar will.
        os.close(archive_fd)

        # Run zip and do the actual archiving. Will block until it's finished.
        zipdir(submission.getFilePath(), archive_file_name)

        new_archive.file_location = archive_file_name

        new_archive.save(force_insert = True)

        return send_file(archive_file_name)
    except Exception as e:
        logger.exception("An error occured while creating an archive.")

        # If we created a temporary archive file we need to delete it.
        new_archive.file_location = None
        if archive_file_name:
            os.remove(archive_file_name)

        new_archive.error_string = str(e)
        new_archive.save(force_insert = True)

        abort(500)
Esempio n. 2
0
    archive_file_name = ""
    try:
        # Create the actual archive file.
        # TODO: Create it in galah's /var/ directory
        archive_fd, archive_file_name = tempfile.mkstemp(suffix=".zip")

        # Close the file because we won't actually do any writing to it,
        # rather tar will.
        os.close(archive_fd)

        # Run zip and do the actual archiving. Will block until it's finished.
        zipdir(submission.getFilePath(), archive_file_name)

        new_archive.file_location = archive_file_name

        new_archive.save(force_insert=True)

        return send_file(archive_file_name)
    except Exception as e:
        logger.exception("An error occured while creating an archive.")

        # If we created a temporary archive file we need to delete it.
        new_archive.file_location = None
        if archive_file_name:
            os.remove(archive_file_name)

        new_archive.error_string = str(e)
        new_archive.save(force_insert=True)

        abort(500)