def get_mountpoint_runner(): # Windows if os.name == "nt": try: # Use import function for easier mock up import_function("winfspy") except RuntimeError as exc: raise MountpointWinfspNotAvailable(exc) from exc logging.getLogger("winfspy").setLevel(logging.WARNING) from parsec.core.mountpoint.winfsp_runner import winfsp_mountpoint_runner return winfsp_mountpoint_runner # Linux else: try: # Use import function for easier mock up import_function("fuse") except (ImportError, OSError) as exc: raise MountpointFuseNotAvailable(exc) from exc logging.getLogger("fuse").setLevel(logging.WARNING) from parsec.core.mountpoint.fuse_runner import fuse_mountpoint_runner return fuse_mountpoint_runner
MountpointAlreadyMounted, MountpointNotMounted, MountpointWinfspNotAvailable, MountpointFuseNotAvailable, MountpointError, ) from parsec.core.mountpoint.winify import winify_entry_name from parsec.core.win_registry import cleanup_parsec_drive_icons # Importing winfspy can take some time (about 0.4 seconds) # Let's import those bindings at module level, in order to # avoid spending too much time importing them later while the # trio loop is running. try: if os.name == "nt": import_function("winfspy") else: import_function("fuse") except (ImportError, RuntimeError, OSError): pass logger = get_logger() def get_mountpoint_runner(): # Windows if os.name == "nt": try: # Use import function for easier mock up import_function("winfspy")