diff --git a/dvc/system.py b/dvc/system.py index 6de1fa75b..174414626 100644 --- a/dvc/system.py +++ b/dvc/system.py @@ -5,7 +5,6 @@ import subprocess from builtins import str if os.name == 'nt': - from ctypes import create_unicode_buffer, windll import ntfsutils.hardlink as winlink @@ -33,51 +32,3 @@ class System(object): return os.path.samefile(path1, path2) return winlink.samefile(path1, path2) - - @staticmethod - def _get_symlink_string(path): - p = subprocess.Popen(["dir", path], shell=True) - output, _ = p.communicate() - if p.returncode != 0 or output == None: - return None - - lines = output.split('\n') - for line in lines: - if System.SYMLINK_OUTPUT in line: - return line - return None - - @staticmethod - def realpath(path): - # It is definitely not the best way to check a symlink. - - if System.is_unix(): - return os.path.realpath(path) - - output = System._get_symlink_string(path) - if output is None: - return os.path.realpath(path) - - groups = re.compile(r'\[\S+\]$').findall(output.strip()) - if len(groups) < 1: - return os.path.realpath(path) - - resolved_link = groups[0][1:-1] - return resolved_link - - @staticmethod - def get_long_path(path): - """Convert short path to a full path. It is needed for Windows.""" - if System.is_unix(): - return path - - buffer = ctypes.create_unicode_buffer(System.LONG_PATH_BUFFER_SIZE) - get_long_path_name = ctypes.windll.kernel32.GetLongPathNameW - result = get_long_path_name(u'%s' % str(path), buffer, System.LONG_PATH_BUFFER_SIZE) - if result == 0 or result > System.LONG_PATH_BUFFER_SIZE: - return path - return buffer.value - - @staticmethod - def get_cwd(): - return System.get_long_path(os.getcwd()) diff --git a/tests/basic_env.py b/tests/basic_env.py index 6dcd98280..4101b9494 100644 --- a/tests/basic_env.py +++ b/tests/basic_env.py @@ -4,7 +4,6 @@ import tempfile from git import Repo from unittest import TestCase -from dvc.system import System from dvc.project import Project @@ -23,7 +22,7 @@ class TestDir(TestCase): CODE_CONTENTS = 'import sys\nimport shutil\nshutil.copyfile(sys.argv[1], sys.argv[2])' def _pushd(self, d): - self._saved_dir = System.realpath(os.curdir) + self._saved_dir = os.path.realpath(os.curdir) os.chdir(d) def _popd(self): @@ -35,7 +34,7 @@ class TestDir(TestCase): f.write(contents) def setUp(self): - self._root_dir = System.get_long_path(tempfile.mkdtemp()) + self._root_dir = tempfile.mkdtemp() self._pushd(self._root_dir) self.create(self.FOO, self.FOO_CONTENTS) self.create(self.BAR, self.BAR_CONTENTS)