88
99platform = platform .system ()
1010
11+
1112class FSMount (Command ):
12-
13+
1314 if platform == "Windows" :
1415 usage = """fsmount [OPTIONS]... [FS] [DRIVE LETTER]
1516or fsmount -u [DRIVER LETTER]
@@ -20,121 +21,119 @@ class FSMount(Command):
2021Mounts a file system on a system path"""
2122
2223 version = "1.0"
23-
24+
2425 def get_optparse (self ):
25- optparse = super (FSMount , self ).get_optparse ()
26+ optparse = super (FSMount , self ).get_optparse ()
2627 optparse .add_option ('-f' , '--foreground' , dest = 'foreground' , action = "store_true" , default = False ,
2728 help = "run the mount process in the foreground" , metavar = "FOREGROUND" )
2829 optparse .add_option ('-u' , '--unmount' , dest = 'unmount' , action = "store_true" , default = False ,
2930 help = "unmount path" , metavar = "UNMOUNT" )
3031 optparse .add_option ('-n' , '--nocache' , dest = 'nocache' , action = "store_true" , default = False ,
3132 help = "do not cache network filesystems" , metavar = "NOCACHE" )
32-
33+
3334 return optparse
34-
35-
35+
3636 def do_run (self , options , args ):
37-
37+
3838 windows = platform == "Windows"
39-
39+
4040 if options .unmount :
4141
4242 if windows :
43-
44- try :
43+
44+ try :
4545 mount_path = args [0 ][:1 ]
4646 except IndexError :
4747 self .error ('Driver letter required\n ' )
4848 return 1
49-
49+
5050 from fs .expose import dokan
5151 mount_path = mount_path [:1 ].upper ()
5252 self .output ('unmounting %s:...\n ' % mount_path , True )
53- dokan .unmount (mount_path )
53+ dokan .unmount (mount_path )
5454 return
55-
56- else :
57- try :
55+
56+ else :
57+ try :
5858 mount_path = args [0 ]
5959 except IndexError :
6060 self .error (self .usage + '\n ' )
61- return 1
62-
61+ return 1
62+
6363 from fs .expose import fuse
6464 self .output ('unmounting %s...\n ' % mount_path , True )
65- fuse .unmount (mount_path )
65+ fuse .unmount (mount_path )
6666 return
67-
67+
6868 try :
6969 fs_url = args [0 ]
7070 except IndexError :
7171 self .error (self .usage + '\n ' )
7272 return 1
73-
74- try :
73+
74+ try :
7575 mount_path = args [1 ]
7676 except IndexError :
7777 if windows :
7878 mount_path = mount_path [:1 ].upper ()
7979 self .error (self .usage + '\n ' )
8080 else :
8181 self .error (self .usage + '\n ' )
82- return 1
83-
82+ return 1
83+
8484 fs , path = self .open_fs (fs_url , create_dir = True )
8585 if path :
8686 if not fs .isdir (path ):
87- self .error ('%s is not a directory on %s' % (fs_url . fs ))
87+ self .error ('%s is not a directory on %s' % (fs_url , fs ))
8888 return 1
8989 fs = fs .opendir (path )
9090 path = '/'
9191 if not options .nocache :
9292 fs .cache_hint (True )
93-
93+
9494 if windows :
9595 from fs .expose import dokan
96-
96+
9797 if len (mount_path ) > 1 :
9898 self .error ('Driver letter should be one character' )
9999 return 1
100-
100+
101101 self .output ("Mounting %s on %s:\n " % (fs , mount_path ), True )
102102 flags = dokan .DOKAN_OPTION_REMOVABLE
103103 if options .debug :
104104 flags |= dokan .DOKAN_OPTION_DEBUG | dokan .DOKAN_OPTION_STDERR
105-
105+
106106 mp = dokan .mount (fs ,
107107 mount_path ,
108108 numthreads = 5 ,
109109 foreground = options .foreground ,
110110 flags = flags ,
111111 volname = str (fs ))
112-
113- else :
112+
113+ else :
114114 if not os .path .exists (mount_path ):
115115 try :
116116 os .makedirs (mount_path )
117117 except :
118118 pass
119-
119+
120120 from fs .expose import fuse
121121 self .output ("Mounting %s on %s\n " % (fs , mount_path ), True )
122-
122+
123123 if options .foreground :
124124 fuse_process = fuse .mount (fs ,
125- mount_path ,
126- foreground = True )
125+ mount_path ,
126+ foreground = True )
127127 else :
128128 if not os .fork ():
129129 mp = fuse .mount (fs ,
130130 mount_path ,
131131 foreground = True )
132132 else :
133- fs .close = lambda :None
134-
133+ fs .close = lambda : None
134+
135135def run ():
136136 return FSMount ().run ()
137-
137+
138138if __name__ == "__main__" :
139139 sys .exit (run ())
140-
0 commit comments