Great. Then, I think you can replace the last loop with this:
progress("Updating XMP tags...");
i = 0;
for k,f in enumerate(files):
ec = E[k];
cmd = "exiftool -xmp:ExposureCompensation=%f '%s'" % (ec, os.path.join("raw", f))
os.system(cmd)
progress(k / len(files))
or, for separate xmp files:
progress("Creating sidecar XMP files...");
i = 0;
for k,f in enumerate(files):
ec = E[k];
cmd = "exiftool -creator=me -xmp:ExposureCompensation=%f '%s'" % (ec, os.path.join("raw", change_ext(f, '.xmp'))
os.system(cmd)
progress(k / len(files))
Let me know if it works for you. I don't use Aperture nor Lightroom (just ufraw and some scripts).