#!/usr/bin/env python3 import sys import fuse import logging import argparse import httpfs FORMAT = "%(threadName)s %(asctime)-15s %(levelname)s:%(name)s " + \ "%(filename)s:%(lineno)s %(message)s" logging.basicConfig(level=logging.INFO, format=FORMAT) p = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) p.add_argument("mountpoint", help="Target directory") p.add_argument("--max_background", type=int, default=15, help="Maximum number of background threads") p.add_argument("--no_foreground", action="store_true", default=False, help="Fork into background as a daemon") p.add_argument("--debug", action="store_true", help="Enable debug logging") p.add_argument("--debug-requests", action="store_true", help="Enable python-requests debug logging") p.add_argument("--nothreads", action="store_true", help="Disable fuse threads") p.add_argument("--timeout", type=float, default=None, help="HTTP connect and read timeout") p.add_argument("--ssl", choices=["default", "system", "none"], help="SSL Verification", default="default") p.add_argument("--system-ca", default="/etc/ssl/certs/ca-certificates.crt", help="Path to system ca bundle") args = vars(p.parse_args(sys.argv[1:])) httpfs.Config.timeout = args.pop("timeout") httpfs.Config.mountpoint = args.pop("mountpoint") httpfs.Config.verify = args.pop("ssl") httpfs.Config.system_ca = args.pop("system_ca") kwargs = {} if not args.pop("no_foreground"): kwargs["foreground"] = True if args.pop("debug"): kwargs["debug"] = True logging.getLogger(httpfs.__name__).setLevel(logging.DEBUG) if args.pop("debug_requests"): logging.getLogger("requests.packages.urllib3").setLevel(logging.DEBUG) kwargs.update(args) fuse = fuse.FUSE(httpfs.Httpfs(), httpfs.Config.mountpoint, **kwargs)