def updateLink(source, target): if os.path.islink(target): # Remove old, possibly stale link. os.unlink(target) if not os.path.exists(target): # Do not replace existing files. os.symlink(source, target)