A "safe" copy function for Python
As the documentation for shutil.copyfile(src, dst) says,


  If dst already exists, it will be replaced.


You have attempted to work around that by checking if not os.path.exists(dst) first.  However, that logic is vulnerable to a race condition if the destination file springs into existence just after the check.

A way to ensure that you do not overwrite an existing file is to use os.open() with the os.O_EXCL flag.  You would need to write the read-write loop yourself to transfer the file contents, but that is not difficult.