コード例 #1
0
class MountpointStats(StatsParser):
    """Stats for filesystems

    Uses systematic.MountPoints to parse filesystem stats
    """
    parser_name = 'filesystems'

    def __init__(self):
        super(MountpointStats, self).__init__()
        self.mountpoints = MountPoints()
        self.update_timestamp()

    def update(self):
        """Update filesystems

        """
        self.mountpoints.update()
        return self.update_timestamp()

    def to_json(self, verbose=True):
        """Return JSON data

        """
        if self.__updated__ is None:
            self.update()
        return json.dumps(
            {
                'timestamp':
                self.__updated__,
                'filesystems':
                [mp.as_dict(verbose=verbose) for mp in self.mountpoints],
            },
            indent=2,
        )
コード例 #2
0
 def test1_list_mountpoints(self):
     """
     Test listing mount points on this platform
     """
     try:
         mp = MountPoints()
         self.assertIsInstance(mp.keys(), list)
     except FileSystemError, emsg:
         print emsg
         return
コード例 #3
0
    def test1_list_mountpoints(self):

        """
        Test listing mount points on this platform
        """
        try:
            mp = MountPoints()
            self.assertIsInstance(mp.keys(), list)
        except FileSystemError as e:
            print('Error listing mountpoints: {0}'.format(e))
            return
コード例 #4
0
    def test1_list_mountpoints(self):

        """
        Test listing mount points on this platform
        """
        try:
            mp = MountPoints()
            self.assertIsInstance(mp.keys(), list)
        except FileSystemError, emsg:
            print emsg
            return
コード例 #5
0
def test_mountpoint_sorting(platform_mock_binaries):
    """Test sorting of mountpoints

    """
    from systematic.filesystems import MountPoints
    mounts = MountPoints()

    values = sorted(mp for mp in mounts)
    assert len(values) == len(mounts)

    mounts.sort()
    for i, mp in enumerate(mounts):
        assert mp == values[i]
コード例 #6
0
ファイル: test_mountpoints.py プロジェクト: hile/systematic
def test_mountpoint_sorting(platform_mock_binaries):
    """Test sorting of mountpoints

    """
    from systematic.filesystems import MountPoints
    mounts = MountPoints()

    values = sorted(mp for mp in mounts)
    assert len(values) == len(mounts)

    mounts.sort()
    for i, mp in enumerate(mounts):
        assert mp == values[i]
コード例 #7
0
 def test2_check_mounpoint_type(self):
     """
     Check object type of returned filesystems
     """
     try:
         mp = MountPoints()
     except FileSystemError, emsg:
         print emsg
         return
コード例 #8
0
def test_mountpoint_attributes(platform_mock_binaries):
    """Test mountpoint attributes

    """

    from systematic.filesystems import MountPoints
    from systematic.classes import MountPoint

    mounts = MountPoints()
    assert len(mounts) > 0

    for mp in mounts:
        assert isinstance(mp, MountPoint)

        assert isinstance(mp.path, str)
        assert isinstance(mp.name, str)

        assert isinstance(mp.usage, dict)
        assert isinstance(mp.flags, dict)

        assert isinstance(mp.size, int)
        assert isinstance(mp.used, int)
        assert isinstance(mp.available, int)
        assert isinstance(mp.free, int)
        assert isinstance(mp.percent, int)

        assert isinstance(mp.as_dict(), dict)
        json.dumps(mp.as_dict())

        # Only available with MacOS (darwin) ps output
        if hasattr(mp, 'blocksize'):
            assert isinstance(mp.blocksize, int)
        for attr in ('internal', 'writable', 'bootable', 'ejectable',
                     'removable'):
            if hasattr(mp, attr):
                assert isinstance(getattr(mp, attr), bool)
コード例 #9
0
 def __init__(self):
     super(MountpointStats, self).__init__()
     self.mountpoints = MountPoints()
     self.update_timestamp()