Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #417: replace os.rename #418

Merged
merged 1 commit into from Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/e3/anod/sandbox/migrate.py
Expand Up @@ -40,6 +40,7 @@ def migrate_v1_5() -> None:
"""
from glob import glob
import os
from e3.fs import mv

for f in glob("*.yaml"):
print("looking at %s" % f)
Expand All @@ -50,7 +51,7 @@ def migrate_v1_5() -> None:
except OSError:
pass
try:
os.rename(name + ".yaml", os.path.join(name, "config.yaml"))
mv(name + ".yaml", os.path.join(name, "config.yaml"))
except OSError: # defensive code
print("error for %s" % name)
elif "-" in name:
Expand All @@ -64,7 +65,7 @@ def migrate_v1_5() -> None:
os.mkdir(prefix)
except OSError: # defensive code
pass
os.rename(name + ".yaml", os.path.join(prefix, "%s.yaml" % suffix))
mv(name + ".yaml", os.path.join(prefix, "%s.yaml" % suffix))
except Exception as er: # defensive code
print(f"error for {name}.yaml {prefix} {suffix}")
print(er)
Expand Down
4 changes: 2 additions & 2 deletions src/e3/store/cache/backends/filecache.py
Expand Up @@ -8,7 +8,7 @@
from typing import TYPE_CHECKING

import e3.log
from e3.fs import mkdir, rm
from e3.fs import mkdir, rm, mv
from e3.store.cache.backends.base import DEFAULT_TIMEOUT, Cache

try:
Expand Down Expand Up @@ -91,7 +91,7 @@ def set(self, uid: str, value: Any, timeout: int = DEFAULT_TIMEOUT) -> bool:
# atomic rename does not work on windows if the dest file
# already exist
rm(dest_file)
os.rename(tmp_file.name, dest_file)
mv(tmp_file.name, dest_file)
return True

finally:
Expand Down
3 changes: 2 additions & 1 deletion tests/fix-coverage-paths.py
Expand Up @@ -6,6 +6,7 @@


import os
import shutil
import sys

from coverage.sqldata import CoverageData
Expand All @@ -21,7 +22,7 @@ def fix_paths(site_pkg_dir, cov_data_file):

old_cov_file = NamedTemporaryFile()
old_cov_file.close()
os.rename(cov_data_file, old_cov_file.name)
shutil.move(cov_data_file, old_cov_file.name)

old_coverage_data = CoverageData(old_cov_file.name)
old_coverage_data.read()
Expand Down
3 changes: 2 additions & 1 deletion tests/tests_e3/fs/main_test.py
@@ -1,5 +1,6 @@
import os
import sys
import shutil

import e3.diff
import e3.fs
Expand Down Expand Up @@ -253,7 +254,7 @@ def test_sync_tree_case_insensitive():

# Adjust some casing of a file that is up-to-date. Sync_tree should be case
# preserving and thus adjust the casing
os.rename("test/b/OLD2.txt", "test/b/Old2.txt")
shutil.move("test/b/OLD2.txt", "test/b/Old2.txt")
e3.fs.sync_tree("test/a", "test/b")
assert e3.fs.directory_content("test/b") == e3.fs.directory_content("test/a")

Expand Down