--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/0339ec15-602e-4bb7-889a-4ebd211e7a72n%40googlegroups.com.
Thanks. To clarify, I meant that if I log into WeBWorK and open a .pg file with TikZ in it, it renders correctly.
I just tried building the sample chapter against my server. I'm not seeing any warnings about missing images, but a few problems aren't building successfully on my server: 62, 63, 64, 65, 67, and 68. I'm not sure which ones these are.
I'll try to find some time to dig around later.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/CA%2BR-jrduHM0L-eXZmjgWMQ9eCZoyUfPtNhmSk%3Dsc17m9gZxBKg%40mail.gmail.com.
It may help to put labels on exercises, and then I think you will be more easily able to locate the corresponding source.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/CAH%2BNcPYYLFfdarWXi%3DpnsLF9Rnx-swj7_ctnfjEFqCfv0-7Q%3DA%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/CA%2BR-jrd9My-TMpmo4WJayGEzsX8ySvVX1BrRvep1sZd4Y_BsVw%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/e26014e2-d3fc-48c7-9d15-d39b13955d08n%40googlegroups.com.
I've just left my office! (And the computers contained therein.) But I'll send you the log files tomorrow.
I can download the .tgz files from the server onto my Windows computer, and open them, and confirm that they have contents. So I'm not sure why pretext thinks they're empty.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/CAOU9BaX1b2Br8T0PcKJnawXfKd_zeuijABVhTAcTgf6cKApYiQ%40mail.gmail.com.
I dug through pretext/lib/webwork.py, the code path that pulls WeBWorK-rendered images (~line 630–729 in the image-download loop). The likely culprit is here:
if image_extension == ".tgz":
tgzfile = tarfile.open(destination_image_file)
tgzfile.extractall(os.path.join(ww_images_dir))
tgzfile.close()
msg = "{} did not contain a .{} file"
for ext in ["tex", "pdf", "svg", "png"]:
try:
os.rename(
os.path.join(ww_images_dir, "image.{}".format(ext)),
os.path.join(ww_images_dir, ptx_image_name + ".{}".format(ext)),
)
except:
log.warning(msg.format(destination_image_file, ext))
os.remove(os.path.join(ww_images_dir, ptx_image_filename))The tgz is extracted (producing image.tex, image.pdf, etc. in ww_images_dir), then each is renamed to the problem-specific filename with os.rename.
That os.rename call is the OS-sensitive spot. os.rename behaves differently on Windows vs. POSIX/Linux when the destination file already exists: on Linux it silently overwrites; on Windows it raises FileExistsError instead. This code swallows that error with a bare except, so on Windows every rename after the first successful build (or any rerun where a target file with that name already exists in ww_images_dir) fails, and you get exactly the four warnings ("did not contain a .tex/.pdf/.svg/.png file") reported — even though the tgz genuinely contained those files and extraction succeeded. This matches the reporter's experience: same source, same WeBWorK server, works cleanly on Linux, fails consistently on Windows, and the "empty tgz" framing was a red herring from an earlier, separate server-side issue (localOverrides.conf temp dirs) that they'd already fixed.
The fix (not applied, since you asked me not to debug) would be replacing os.rename with os.replace, which has consistent overwrite-if-exists semantics on both platforms — or explicitly removing any stale target file before renaming.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/3b134f4c-24c4-4085-831b-35a911d9c1c1n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/MTAwMDAyMXdqZnlGZ3c.1785164499%40pnsh.