Best Python code snippet using avocado_python
partition.py
Source:partition.py  
...202            except process.CmdError as details:203                raise PartitionError(self, "Mount failed", details)204        # Update the fstype as the mount command passed205        self.fstype = fstype206    def _get_pids_on_mountpoint(self, mnt):207        """208        Returns a list of processes using a given mountpoint209        """210        try:211            cmd = "lsof " + mnt212            out = process.system_output(cmd, sudo=True)213            return [int(line.split()[1]) for line in out.splitlines()[1:]]214        except OSError as details:215            msg = 'Could not run lsof to identify processes using "%s"' % mnt216            LOG.error(msg)217            raise PartitionError(self, msg, details)218        except process.CmdError as details:219            msg = 'Failure executing "%s"' % cmd220            LOG.error(msg)221            raise PartitionError(self, msg, details)222    def _unmount_force(self, mountpoint):223        """224        Kill all other jobs accessing this partition and force unmount it.225        :return: None226        :raise PartitionError: On critical failure227        """228        for pid in self._get_pids_on_mountpoint(mountpoint):229            try:230                process.system("kill -9 %d" % pid, ignore_status=True, sudo=True)231            except process.CmdError as details:232                raise PartitionError(self, "Failed to kill processes", details)233        # Unmount234        try:235            process.run("umount -f %s" % mountpoint, sudo=True)236        except process.CmdError as details:237            try:238                process.run("umount -l %s" % mountpoint, sudo=True)239            except process.CmdError as details:240                raise PartitionError(self, "Force unmount failed", details)241    def unmount(self, force=True):242        """...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
