chrrrisw / kmel_db

A parser and generator for Kenwood Music Editor Light databases
Apache License 2.0
6 stars 1 forks source link

get_fat_mounts doesn't handle mount output on Mac #11

Open arthurjy opened 8 years ago

arthurjy commented 8 years ago

There are not 6 tokens to split line into. Example Mac output:-

/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
//arthur@boadicea._afpovertcp._tcp.local/Media on /Volumes/Media (afpfs, nodev, nosuid, mounted by arthur)
//arthur@boadicea._afpovertcp._tcp.local/arthur%60s%20home on /Volumes/arthur's home (afpfs, nodev, nosuid, mounted by arthur)
/dev/disk1s1 on /Volumes/KENWOOD (msdos, local, nodev, nosuid, noowners)

Also note, the FAT formatted volume has a filesystem attribute of 'msdos'

I progressed past this point with this temporary fix:-

def get_fat_mounts():
    fat_mounts = []
    mounts = os.popen('mount')
    for line in mounts.readlines():
        #device, ign1, mount_point, ign2, filesystem, options = line.split()
        parts = line.split();
        device = parts[0];
        mount_point = parts[2];

        if 'fat' in line or 'msdos' in line:
            fat_mounts.append((mount_point, 'fat', device))
    return fat_mounts

However the checking if the mount point is of FAT (or MSDOS) type needs to be more robust.

chrrrisw commented 8 years ago

Thanks @arthurjy, will attempt to make more robust. Thanks for the Mac output, it differs from the Linux output which prints the filesystem type separately. Regards, Chris.

chrrrisw commented 8 years ago

Hi @arthurjy, I have pushed a change to the mac_os branch which now uses psutil to get the disk partitions.

If you pull the latest changes, change to the mac_os branch, you should be able to run the mounts.py file to see a list of the mount points. You'll need to install the 'psutil' library to use the new functionality, but it will fall back to the logic you have above.

git pull
git checkout mac_os
cd kmeldb
python3 mounts.py

I'd appreciate it if you post the output here, so I can see how it's working. If you have 'psutil' installed it will actually run the test twice (once with psutil, once with the fallback) and compare the results.