def is_mounted(self):
        """Test for whether a mount point is mounted.

        If it is currently mounted, determine the path where it's
        mounted and update the connection's mount_point accordingly.
        """
        mount_check = subprocess.check_output("mount").splitlines()
        # The mount command returns lines like this on OS X...
        # //username@pretendco.com/JSS%20REPO on /Volumes/JSS REPO
        # (afpfs, nodev, nosuid, mounted by local_me)
        # and like this on Linux...
        # //pretendco.com/jamf on /mnt/jamf type cifs (rw,relatime,
        # <options>...)

        valid_mount_strings = self._get_valid_mount_strings()
        was_mounted = False
        if is_osx():
            mount_string_regex = re.compile(r"\(([\w]*),*.*\)$")
            mount_point_regex = re.compile(r"on ([\w/ -]*) \(.*$")
        elif is_linux():
            mount_string_regex = re.compile(r"type ([\w]*) \(.*\)$")
            mount_point_regex = re.compile(r"on ([\w/ -]*) type .*$")
        else:
            raise JSSError("Unsupported OS.")

        for mount in mount_check:
            fs_match = re.search(mount_string_regex, mount)
            fs_type = fs_match.group(1) if fs_match else None
            # Automounts, non-network shares, and network shares
            # all have a slightly different format, so it's easiest to
            # just split.
            mount_string = mount.split(" on ")[0]
            # Does the mount_string match one of our valid_mount_strings?
            if [mstring for mstring in valid_mount_strings if
                    mstring in mount_string] and self.fs_type == fs_type:
                # Get the mount point string between from the end back to
                # the last "on", but before the options (wrapped in
                # parenthesis). Considers alphanumerics, / , _ , - and a
                # blank space as valid, but no crazy chars.
                match = re.search(mount_point_regex, mount)
                mount_point = match.group(1) if match else None
                was_mounted = True
                # Reset the connection's mount point to the discovered
                # value.
                if mount_point:
                    self.connection["mount_point"] = mount_point
                    if self.connection["jss"].verbose:
                        print ("%s is already mounted at %s.\n" %
                               (self.connection["url"], mount_point))

                # We found the share, no need to continue.
                break

        if not was_mounted:
            # If the share is not mounted, check for another share
            # mounted to the same path and if found, incremement the
            # name to avoid conflicts.
            count = 1
            while os.path.ismount(self.connection["mount_point"]):
                self.connection["mount_point"] = (
                    "%s-%s" % (self.connection["mount_point"], count))
                count += 1

        # Do an inexpensive double check...
        return os.path.ismount(self.connection["mount_point"])
def is_mounted ( self ) : mount_check = subprocess . check_output ( "mount" ) . splitlines ( ) valid_mount_strings = self . _get_valid_mount_strings ( ) was_mounted = False if is_osx ( ) : mount_string_regex = re . compile ( r"\(([\w]*),*.*\)$" ) mount_point_regex = re . compile ( r"on ([\w/ -]*) \(.*$" ) elif is_linux ( ) : mount_string_regex = re . compile ( r"type ([\w]*) \(.*\)$" ) mount_point_regex = re . compile ( r"on ([\w/ -]*) type .*$" ) else : raise JSSError ( "Unsupported OS." ) for mount in mount_check : fs_match = re . search ( mount_string_regex , mount ) fs_type = fs_match . group ( 1 ) if fs_match else None mount_string = mount . split ( " on " ) [ 0 ] if [ mstring for mstring in valid_mount_strings if mstring in mount_string ] and self . fs_type == fs_type : match = re . search ( mount_point_regex , mount ) mount_point = match . group ( 1 ) if match else None was_mounted = True if mount_point : self . connection [ "mount_point" ] = mount_point if self . connection [ "jss" ] . verbose : print ( "%s is already mounted at %s.\n" % ( self . connection [ "url" ] , mount_point ) ) break if not was_mounted : count = 1 while os . path . ismount ( self . connection [ "mount_point" ] ) : self . connection [ "mount_point" ] = ( "%s-%s" % ( self . connection [ "mount_point" ] , count ) ) count += 1 return os . path . ismount ( self . connection [ "mount_point" ] )
Test for whether a mount point is mounted.

        If it is currently mounted, determine the path where it's
        mounted and update the connection's mount_point accordingly.