Skip to content

Commit

Permalink
Merge pull request #4688 from jedwards4b/remove_distutils
Browse files Browse the repository at this point in the history
Remove distutils
  • Loading branch information
jedwards4b authored Oct 1, 2024
2 parents 9ac3e71 + cf996bf commit 98fc664
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from argparse import Action
from contextlib import contextmanager

# pylint: disable=deprecated-module
from distutils import file_util

# Return this error code if the scripts worked but tests failed
TESTS_FAILED_ERR_CODE = 100
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1412,26 +1409,25 @@ def safe_copy(src_path, tgt_path, preserve_meta=True):

if owner_uid == os.getuid():
# I am the owner, copy file contents, permissions, and metadata
file_util.copy_file(
shutil.copy2(
src_path,
tgt_path,
preserve_mode=preserve_meta,
preserve_times=preserve_meta,
verbose=0,
)
else:
# I am not the owner, just copy file contents
shutil.copyfile(src_path, tgt_path)

else:
elif preserve_meta:
# We are making a new file, copy file contents, permissions, and metadata.
# This can fail if the underlying directory is not writable by current user.
file_util.copy_file(
shutil.copy2(
src_path,
tgt_path,
)
else:
shutil.copy(
src_path,
tgt_path,
preserve_mode=preserve_meta,
preserve_times=preserve_meta,
verbose=0,
)

# If src file was executable, then the tgt file should be too
Expand Down

0 comments on commit 98fc664

Please sign in to comment.