Skip to content

Commit 4729004

Browse files
committed
keep uftpfs connection details
1 parent 50e9ed6 commit 4729004

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-13
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Changelog for PyUNICORE
33

44
Issue tracker: https://github.com/HumanBrainProject/pyunicore
55

6-
Version 1.3.0 (mmm dd, 2025)
6+
Version 1.3.0 (May 12, 2025)
77
----------------------------
88
- new feature: CLI: implemented more authentication options
99
(oidc-agent, oidc-server, anonymous)

pyunicore/credentials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_token(self):
7272

7373
class BearerToken(Credential):
7474
"""
75-
Produces a header value "Basic <auth_token>"
75+
Produces a header value "Bearer <auth_token>"
7676
7777
Args:
7878
token: the value of the auth token

pyunicore/uftp/uftpfs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ class UFTPFS(FTPFS):
3737

3838
def __init__(self, auth_url, creds, base_path="/"):
3939
"""Creates a new UFTP FS instance authenticating using the given URL and credentials"""
40-
uftp_host, uftp_port, uftp_password = UFTP().authenticate(creds, auth_url, base_path)
41-
super().__init__(uftp_host, port=uftp_port, user="anonymous", passwd=uftp_password)
40+
self.uftp_host, self.uftp_port, self.uftp_password = UFTP().authenticate(
41+
creds, auth_url, base_path
42+
)
43+
super().__init__(
44+
self.uftp_host, port=self.uftp_port, user="anonymous", passwd=self.uftp_password
45+
)
4246
self.base_path = base_path
4347

4448
def hassyspath(self, path):

pyunicore/uftp/uftpfuse.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
264286
if __name__ == "__main__":
265287
main()

pyunicore/uftp/uftpmountfs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class UFTPMOUNTFS(OSFS):
3838

3939
def __init__(self, auth_url, creds, base_path="/", mount_dir="./uftp_mount"):
4040
"""Creates a new UFTP FS instance authenticating using the given URL and credentials"""
41-
self.host, self.port, uftp_password = UFTP().authenticate(creds, auth_url, base_path)
41+
self.host, self.port, self.uftp_password = UFTP().authenticate(creds, auth_url, base_path)
4242
self.base_path = base_path
4343
self.mount_dir = mount_dir
4444
self._ensure_unmount()
45-
self._run_fusedriver(uftp_password)
45+
self._run_fusedriver(self.uftp_password)
4646
super().__init__(mount_dir)
4747

4848
def close(self):

0 commit comments

Comments
 (0)