Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USER.ID Not being populated on project. #188

Open
gkowalski opened this issue May 3, 2024 · 1 comment
Open

USER.ID Not being populated on project. #188

gkowalski opened this issue May 3, 2024 · 1 comment

Comments

@gkowalski
Copy link

Running this code :

import xnat
XNAT_USERID = os.environ.get("XNAT_USERID")
XNAT_PASSWORD = os.environ.get("XNAT_PASSWORD")
XNAT_SITE = os.environ.get("XNAT_SITE")
with xnat.connect( server=XNAT_SITE, password=XNAT_PASSWORD, user=XNAT_USERID) as session:

for user in session.users.values():
print( f"User = {user} ")
print( f"User email = {user.email} ")
print( f"XNAT id = {user.id} ")

Prints the user.id for each user

But this code returns "None" for the user.id , but the email VALUE comes thru :

import xnat
XNAT_USERID = os.environ.get("XNAT_USERID")
XNAT_PASSWORD = os.environ.get("XNAT_PASSWORD")
XNAT_SITE = os.environ.get("XNAT_SITE")
with xnat.connect( server=XNAT_SITE, password=XNAT_PASSWORD, user=XNAT_USERID) as session:

myproject = session.projects['IDSC1077']

for user in myproject.users.values():
print( f"User = {user} ")
print( f"User email = {user.email} ")
print( f"XNAT id = {user.id} ") # EMPTY WHEN QUerying on project

@jhuguetn
Copy link
Contributor

jhuguetn commented May 3, 2024

Hi @gkowalski,

I suspect your code uses xnatpy and not pyxnat so there's not much we can do. Nevertheless, you can easily do as follows working with pyxnat if you want to:

import pyxnat
with pyxnat.Interface( server=XNAT_SITE, password=XNAT_PASSWORD, user=XNAT_USERID) as session:
    print([(usr, session.manage.users.id(usr), session.manage.users.email(usr)) for usr in session.manage.users()])

And at project level (split by user role),

import pyxnat
with pyxnat.Interface( server=XNAT_SITE, password=XNAT_PASSWORD, user=XNAT_USERID) as session:
    myproject = session.select.project('IDSC1077')
    print([(usr, session.manage.users.id(usr), session.manage.users.email(usr)) for usr in myproject.owners()])
    print([(usr, session.manage.users.id(usr), session.manage.users.email(usr)) for usr in myproject.members()])
    print([(usr, session.manage.users.id(usr), session.manage.users.email(usr)) for usr in myproject.collaborators()])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants