in usb_monitor_pkg/usb_monitor_pkg/mount_point_tracker.py [0:0]
def umount_filesystem(self, target):
"""Helper function to execute the unmount command on the target.
Args:
target (str): Filepath to the mounted filesystem.
Returns:
bool: True if successful else False.
"""
p = subprocess.Popen(["umount", target],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p.communicate()
if p.returncode != 0:
self.logger.error(f"Failed to unmount {target}")
return False
shutil.rmtree(target)
return True