AWS Thinkbox Discussion Forums

How to correctly get username's email address using API

Hi there,

We’re trying out some additional notification systems as part of the post job process and can’t seem to determine the user’s email address when it’s not noted in the job notification field of the job.

I’m trying this (possibly incorrectly) but getting an empty value. Anyone able to advise or help?

[code]from System.IO import *
from Deadline.Scripting import *
from Deadline.Users import *

def main( *args ):
# Get needed job info
deadlinePlugin = args[0]

#   Todo: Make use of Thinkbox's email storage and configuration system rather than my own.
myjob  = deadlinePlugin.GetJob()
print "USER NAME : "+myjob.UserName
print "Notify:"+str(myjob.JobEmailNotification) # No user email address on job typically, just the job creator's username

user_data = UserInfo()
print "Notfiy on:"+str(user_data.UserEmailNotification)
print "Email address :"+ str(user_data.UserEmailAddress)

current_job_type = myjob.GetJobInfoKeyValue("Plugin")
current_scene_file = myjob.GetJobPluginInfoKeyValue("SceneFile")
current_scene_file = RepositoryUtils.CheckPathMapping(current_scene_file)

[/code]

You’re creating your own copy of UserInfo which is the biggest issue here. You’ll want to use RepositoryUtils.GetUserInfo(name, invalidate). Use “False” for “invalidate” if you know that user data is going to be fresh and “True” if you want to go to the database every time.

Here’s a (slightly modified) working example:

from System.IO import *
from Deadline.Scripting import *
from Deadline.Users import *

def __main__( *args ):
    #   Todo: Make use of Thinkbox's email storage and configuration system rather than my own.
    myjob  = RepositoryUtils.GetJob("58f92203e9faf1fcca5b8c51", True)
    print "USER NAME : "+myjob.UserName
    print "Notify:"+str(myjob.JobEmailNotification) # No user email address on job typically, just the job creator's username

    user_data = RepositoryUtils.GetUserInfo(myjob.UserName, True)
    print "Notfiy on:"+str(user_data.UserEmailNotification)
    print "Email address :"+ str(user_data.UserEmailAddress)

    current_job_type = myjob.GetJobInfoKeyValue("Plugin")
    current_scene_file = myjob.GetJobPluginInfoKeyValue("SceneFile")
    current_scene_file = RepositoryUtils.CheckPathMapping(current_scene_file)
Mobile-029:~ edwin.amsler$ /Applications/Thinkbox/Deadline8/Resources/deadlinecommand executescript /tmp/email.py 
USER NAME : edwin.amsler
Notify:False
Notfiy on:False
Email address :edwin@thinkboxsoftware.com

Many thanks Edwin, that’s perfect.

Cheers

Glad to help amigo. I hope you had a great weekend. :slight_smile:

Privacy | Site terms | Cookie preferences