AWS Thinkbox Discussion Forums

Getting current user's User Groups inside a job script

Hello,

As the title says, I’m trying to get the current user’s User Groups inside a job script. When I run deadlinecommand -GetUserGroupsForUser inside a terminal, it returns the user groups as expected. When I try to run my script inside the Monitor instead, I get either of these:

System.String[] if I print RepositoryUtils.GetUserGroupsForUser(user)

0 if I print subprocess.call([“deadlinecommand”, “-GetUserGroupsForUser”, “user”])

Would it be possible to get a list of strings with the groups the current user belongs to? And would you be able to advise why using subprocess prints 0? Thank you!

You’re getting System.String[] back because we’re actually runnng Python for .NET, and we’re not converting the string array to a python list when we give it back to you. This is really similar to what happened in Issue with SlaveExtraInfoDictionary

To get around it, you’ll have to iterate through that collection like this:

from Deadline.Scripting import RepositoryUtils

def __main__():
    user = "jusbla"
    user_groups = RepositoryUtils.GetUserGroupsForUser(user)

    for group in user_groups:
        print(group)
1 Like
Privacy | Site terms | Cookie preferences