mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Windows symlink: rmtree() and small fixes
This commit is contained in:
+5
-2
@@ -36,8 +36,11 @@ class Runtime(object):
|
||||
if not os.path.exists(path):
|
||||
return False
|
||||
|
||||
# Definitely ont the best way to check a symlink.
|
||||
output = Executor.exec_cmd_only_success("dir", path)
|
||||
if not os.path.isfile(path):
|
||||
return False
|
||||
|
||||
# It is definitely not the best way to check a symlink.
|
||||
output = Executor.exec_cmd_only_success(["dir", path])
|
||||
return '<SYMLINK>' in output
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import os
|
||||
import stat
|
||||
import shutil
|
||||
|
||||
def cached_property(f):
|
||||
def get(self):
|
||||
@@ -12,3 +15,14 @@ def cached_property(f):
|
||||
return x
|
||||
|
||||
return property(get)
|
||||
|
||||
|
||||
def rmtree(dir):
|
||||
'''Cross platform rmtree()'''
|
||||
if os.name == 'nt':
|
||||
if not os.access(dir, os.W_OK):
|
||||
os.chmod(dir, stat.S_IWUSR)
|
||||
else:
|
||||
raise
|
||||
|
||||
shutil.rmtree(dir, ignore_errors=True)
|
||||
|
||||
+3
-3
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import shutil
|
||||
from unittest import TestCase
|
||||
|
||||
from dvc.config import ConfigI
|
||||
@@ -7,6 +6,7 @@ from dvc.git_wrapper import GitWrapperI
|
||||
from dvc.path.data_item import DataItem
|
||||
from dvc.path.factory import PathFactory
|
||||
from dvc.settings import Settings
|
||||
from dvc.utils import rmtree
|
||||
|
||||
|
||||
class BasicEnvironment(TestCase):
|
||||
@@ -16,7 +16,7 @@ class BasicEnvironment(TestCase):
|
||||
self._test_git_dir = os.path.join(self._test_dir, self._proj_dir)
|
||||
self._old_curr_dir_abs = os.path.realpath(os.curdir)
|
||||
|
||||
shutil.rmtree(self._test_dir, ignore_errors=True)
|
||||
rmtree(self._test_dir)
|
||||
|
||||
if curr_dir:
|
||||
self._curr_dir = os.path.realpath(curr_dir)
|
||||
@@ -39,7 +39,7 @@ class BasicEnvironment(TestCase):
|
||||
if self._old_curr_dir_abs:
|
||||
os.chdir(self._old_curr_dir_abs)
|
||||
if self._test_git_dir:
|
||||
shutil.rmtree(self._test_dir, ignore_errors=True)
|
||||
rmtree(self._test_dir)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from unittest import TestCase
|
||||
|
||||
@@ -10,6 +9,7 @@ from dvc.path.data_item import DataItem
|
||||
from dvc.path.factory import PathFactory
|
||||
from dvc.git_wrapper import GitWrapper
|
||||
from dvc.settings import Settings
|
||||
from dvc.utils import rmtree
|
||||
|
||||
|
||||
class RunBasicTest(TestCase):
|
||||
@@ -46,7 +46,7 @@ class RunBasicTest(TestCase):
|
||||
fd.close()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.test_dir, ignore_errors=True)
|
||||
rmtree(self.test_dir)
|
||||
os.chdir(self._old_curr_dir_abs)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user