in usb_monitor_pkg/usb_monitor_pkg/mount_point_tracker.py [0:0]
def mount_filesystem(self, source, target):
"""Helper function to execute mount command to mount the source filesystem to
target filesystem.
Args:
source (str): Filesystem type mounted.
target (str): Filepath to the target filesystem.
Returns:
bool: True if successful else False.
"""
try:
if not os.path.isdir(target):
os.makedirs(target)
except Exception as ex:
return False
p = subprocess.Popen(["mount", source, target],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p.communicate()
if p.returncode != 0:
shutil.rmtree(target)
self.logger.error(f"Failed to mount {source} "
f"to {target}, error code = { p.returncode}")
return False
return True