@@ -87,16 +87,18 @@ def __init__(self, host, port, password, debug=False, read_only=False):
8787 self .host = host
8888 self .port = port
8989 self .password = password
90- self .uftp_session = self .new_session ()
9190 self .last_file = None
9291 self .file_map = {}
9392 self .next_file_handle = 0
9493 self .debug = debug
9594 self .read_only = read_only
95+ self .uftp_session = self .new_session ()
9696
9797 def new_session (self ):
9898 uftp_session = UFTP ()
9999 uftp_session .open_uftp_session (self .host , self .port , self .password )
100+ if self .debug :
101+ print ("UFTP session initialised." )
100102 return uftp_session
101103
102104 def chmod (self , path , mode ):
@@ -228,11 +230,22 @@ def main():
228230 action = "store_true" ,
229231 help = "read-only mode, prevents writes, renames, etc" ,
230232 )
233+ parser .add_argument (
234+ "-f" ,
235+ "--foreground" ,
236+ action = "store_true" ,
237+ help = "run fusedriver in foreground" ,
238+ )
231239 parser .add_argument (
232240 "-P" ,
233241 "--password" ,
234242 help = "one-time password (if not given, it is expected in the environment UFTP_PASSWORD)" ,
235243 )
244+ parser .add_argument (
245+ "-o" ,
246+ "--fuse-options" ,
247+ help = "additional options (key1=value1,key2=value2,...) for fusepy" ,
248+ )
236249 parser .add_argument ("address" , help = "UFTPD server's address (host:port)" )
237250 parser .add_argument (
238251 "mount_point" ,
@@ -248,18 +261,27 @@ def main():
248261 "UFTP one-time password must be given with '-P ...' or as environment UFTP_PASSWORD"
249262 )
250263 _host , _port = args .address .split (":" )
251-
264+ foreground = args .foreground or args .debug
265+ extra_opts = _parse_args (args .fuse_options )
266+ driver = UFTPDriver (_host , int (_port ), _pwd , debug = args .debug , read_only = args .read_only )
252267 FUSE (
253- UFTPDriver ( _host , int ( _port ), _pwd , debug = args . debug , read_only = args . read_only ) ,
268+ driver ,
254269 args .mount_point ,
255270 debug = args .debug ,
256- foreground = args . debug ,
271+ foreground = foreground ,
257272 nothreads = True ,
258- big_writes = True ,
259- max_read = 131072 ,
260- max_write = 131072 ,
273+ ** extra_opts ,
261274 )
262275
263276
277+ def _parse_args (args : str ) -> dict :
278+ result = {}
279+ if args :
280+ for opt in args .split ("," ):
281+ kv = opt .split ("=" )
282+ result [kv [0 ]] = kv [1 ]
283+ return result
284+
285+
264286if __name__ == "__main__" :
265287 main ()
0 commit comments