Coverage for gcsfs/cli/gcsfuse.py: 0%

30 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2026-04-20 18:41 -0400

1import logging 

2 

3import click 

4from fuse import FUSE 

5 

6from gcsfs.gcsfuse import GCSFS 

7 

8 

9@click.command() 

10@click.argument("bucket", type=str, required=True) 

11@click.argument("mount_point", type=str, required=True) 

12@click.option( 

13 "--token", 

14 type=str, 

15 required=False, 

16 default=None, 

17 help="Token to use for authentication", 

18) 

19@click.option( 

20 "--project-id", type=str, required=False, default="", help="Billing Project ID" 

21) 

22@click.option( 

23 "--foreground/--background", 

24 default=True, 

25 help="Run in the foreground or as a background process", 

26) 

27@click.option( 

28 "--threads/--no-threads", default=True, help="Whether to run with threads" 

29) 

30@click.option( 

31 "--cache_files", type=int, default=10, help="Number of open files to cache" 

32) 

33@click.option( 

34 "-v", 

35 "--verbose", 

36 count=True, 

37 help="Set logging level. '-v' for 'gcsfuse' logging." 

38 "'-v -v' for complete debug logging.", 

39) 

40def main( 

41 bucket, mount_point, token, project_id, foreground, threads, cache_files, verbose 

42): 

43 """Mount a Google Cloud Storage (GCS) bucket to a local directory""" 

44 

45 if verbose == 1: 

46 logging.basicConfig(level=logging.INFO) 

47 logging.getLogger("gcsfs.gcsfuse").setLevel(logging.DEBUG) 

48 if verbose > 1: 

49 logging.basicConfig(level=logging.DEBUG) 

50 

51 fmt = "%(asctime)s %(name)-12s %(levelname)-8s %(message)s" 

52 if verbose == 1: 

53 logging.basicConfig(level=logging.INFO, format=fmt) 

54 logging.getLogger("gcsfs.gcsfuse").setLevel(logging.DEBUG) 

55 if verbose > 1: 

56 logging.basicConfig(level=logging.DEBUG, format=fmt) 

57 

58 print(f"Mounting bucket {bucket} to directory {mount_point}") 

59 print("foreground:", foreground, ", nothreads:", not threads) 

60 FUSE( 

61 GCSFS(bucket, token=token, project=project_id, nfiles=cache_files), 

62 mount_point, 

63 nothreads=not threads, 

64 foreground=foreground, 

65 ) 

66 

67 

68if __name__ == "__main__": 

69 main()