HDFGroup / h5pyd

h5py distributed - Python client library for HDF Rest API
Other
110 stars 39 forks source link

Fix hsinfo with endpoint parameter #68

Closed murlock closed 4 years ago

murlock commented 4 years ago

When endpoint was set on cmdline, the endpoint from .hscfg still used from getHomeFolder

jreadey commented 4 years ago

There are some problems with this because the user password is not getting passed to the Folder class.

How about just using the cfg values as so:

def getHomeFolder():
    username = cfg["hs_username"]
    password = cfg["hs_password"]
    endpoint = cfg["hs_endpoint"]
    dir = h5pyd.Folder('/home/', username=username, password=password, endpoint=endpoint)  # get folder object for root
    homefolder = None
    for name in dir:
        # we should come across the given domain
        if username.startswith(name):
            # check any folders where the name matches at least part of the username
            # e.g. folder: "/home/bob/" for username "bob@acme.com"
            path = '/home/' + name + '/'
            try:
                f = h5pyd.Folder(path, username=username, password=password, endpoint=endpoint)
            except IOError as ioe:
                # print("got ioe:", ioe)
                continue
            except Exception as e:
                 # print("got exception:", e)
                continue
            if f.owner == username:
                homefolder = path
            f.close()
            if homefolder:
                break

    dir.close()
    return homefolder
jreadey commented 4 years ago

Hey @murlock - I've incorporated your fix into this commit: https://github.com/HDFGroup/h5pyd/commit/d65fbbf7324509f3c10704877e7361dafcf9f3c9.