version: adjust get_fs_type to discover all partitions

This commit is contained in:
Mr. Outis
2019-09-06 19:27:23 -05:00
parent 05cbe0c922
commit b4507444d5
3 changed files with 16 additions and 3 deletions
+6 -2
View File
@@ -5,6 +5,7 @@ import platform
import argparse
import logging
import uuid
import itertools
try:
import psutil
@@ -69,9 +70,12 @@ class CmdVersion(CmdBaseNoRepo):
def get_fs_type(path):
partition = {
pathlib.Path(part.mountpoint): (part.fstype, part.device)
for part in psutil.disk_partitions()
for part in psutil.disk_partitions(all=True)
}
for parent in pathlib.Path(path).parents:
path = pathlib.Path(path)
for parent in itertools.chain([path], path.parents):
if parent in partition:
return partition[parent]
return ("unkown", "none")
+1
View File
@@ -113,6 +113,7 @@ tests_requirements = [
"Pygments", # required by collective.checkdocs,
"collective.checkdocs",
"flake8",
"psutil",
"flake8-docstrings",
"pydocstyle<4.0",
"jaraco.windows==3.9.2",
+9 -1
View File
@@ -5,8 +5,10 @@ import posixpath
import platform
import pytest
import filecmp
import tempfile
from dvc.system import System
from dvc.command.version import CmdVersion
here = os.path.abspath(os.path.dirname(__file__))
@@ -73,7 +75,9 @@ def test_walk(tmp_path, ssh):
@pytest.mark.skipif(
platform.system() != "Darwin", reason="Only works on OSX (because of APFS)"
CmdVersion.get_fs_type(tempfile.gettempdir())[0]
not in ["xfs", "apfs", "btrfs"],
reason="Reflinks only work in specified file systems",
)
def test_reflink(repo_dir, ssh):
ssh.reflink("foo", "link")
@@ -82,6 +86,10 @@ def test_reflink(repo_dir, ssh):
assert not System.is_hardlink("link")
@pytest.mark.skipif(
platform.system() != "Windows",
reason="sftp symlink is not supported on Windows",
)
def test_symlink(repo_dir, ssh):
ssh.symlink("foo", "link")
assert System.is_symlink("link")