import errno
import os
for name in fullnames:
    source_name = os.path.join(java_path, name)
dest_name = os.path.join(install_path, name)
dest_dir = os.path.dirname(dest_name)
try:
    os.makedirs(dest_dir)
except OSError as exc:
    if exc.errno != errno.EEXIST:
        raise
shutil.copyfile(source_name, dest_name)
Debugging strategy for a bug (apparently) affected by timing