Skip to content

Commit 98fc664

Browse files
authored
Merge pull request #4688 from jedwards4b/remove_distutils
Remove distutils
2 parents 9ac3e71 + cf996bf commit 98fc664

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

CIME/utils.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
from argparse import Action
1313
from contextlib import contextmanager
1414

15-
# pylint: disable=deprecated-module
16-
from distutils import file_util
17-
1815
# Return this error code if the scripts worked but tests failed
1916
TESTS_FAILED_ERR_CODE = 100
2017
logger = logging.getLogger(__name__)
@@ -1412,26 +1409,25 @@ def safe_copy(src_path, tgt_path, preserve_meta=True):
14121409

14131410
if owner_uid == os.getuid():
14141411
# I am the owner, copy file contents, permissions, and metadata
1415-
file_util.copy_file(
1412+
shutil.copy2(
14161413
src_path,
14171414
tgt_path,
1418-
preserve_mode=preserve_meta,
1419-
preserve_times=preserve_meta,
1420-
verbose=0,
14211415
)
14221416
else:
14231417
# I am not the owner, just copy file contents
14241418
shutil.copyfile(src_path, tgt_path)
14251419

1426-
else:
1420+
elif preserve_meta:
14271421
# We are making a new file, copy file contents, permissions, and metadata.
14281422
# This can fail if the underlying directory is not writable by current user.
1429-
file_util.copy_file(
1423+
shutil.copy2(
1424+
src_path,
1425+
tgt_path,
1426+
)
1427+
else:
1428+
shutil.copy(
14301429
src_path,
14311430
tgt_path,
1432-
preserve_mode=preserve_meta,
1433-
preserve_times=preserve_meta,
1434-
verbose=0,
14351431
)
14361432

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

0 commit comments

Comments
 (0)