Event plugin api questions

Hi guys, I have a few question on the Event plugin api.

  1. There doesn’t seem to have a api command to the an extraInfoKeyValue with default.
    There is this command: GetJobExtraInfoKeyValue(‘key’) and I tried this one GetJobExtraInfoKeyValueWithDefault(‘key’) but it failed.
    I would like to be able to do similar to the python dictionary get method.
    ex.:
    a = {‘keyOne’: ‘value1’, ‘keyTwo’: ‘value2’}
    print a.get(‘keyOne’, ‘’)

value1
print a.get(‘keyThree’, ‘default’)
‘default’

Right now my workaround is to use try/except in each GetJobExtraInfoKeyValue calls, but I am not a fan of this workaround.

  1. Is there a way to get all the extraInfoKeyValue dictionary in one command instead of querying each key separately?

  2. I notice that the Shotgun plugin is using the ClientUtils.LogText(‘Doing stuff…’) instead of the self.LogInfo() command.
    Both seem to log in the console and the event log file, so I am not sure why would the ClientUtils.LogText() would be better.

Could you explain why I should use one over the other?

Thanks

Hey Sylvan,

  1. There isn’t, but we can add one in 6.2. Currently, job.GetJobExtraInfoKeyValue() will return an empty string if they key isn’t found, so there is no need to wrap in a try/except block. You can just check for an empty string instead.

  2. Use job.GetJobExtraInfoKeys(). It returns an array of all the extra info keys.

  3. It doesn’t really matter which one you use. LogInfo will just prefix the text with “INFO:”, while LogText won’t prefix the text with anything. Note that LogText is a static utility function that is available to any script that runs in the context of Deadline, whereas LogInfo is a member function of the DeadlineEventListener class.

Hope this helps!
Ryan

Hi Ryan,
thanks for the infos.

I think it would be great to have a GetJobExtraInfoKeyValueWithDefault to match all the other GetJobSomethingWithDefault

It would also be good to list all the available triggers in the docs (they might be there but I didn’t found them yet).
I have found these so far by looking at the examples and by trial and error
self.OnJobSubmittedCallback += self.OnJobSubmitted
self.OnJobStartedCallback += self.OnJobStarted
self.OnJobSuspendedCallback += self.OnJobSuspended
self.OnJobPendedCallback += self.OnJobPended
self.OnJobFinishedCallback += self.OnJobFinished
self.OnJobRequeuedCallback += self.OnJobRequeued
self.OnJobFailedCallback += self.OnJobFailed

You can find the available triggers for the DeadlineEventListener class in the Scripting Reference:
thinkboxsoftware.com/deadlin … mentation/

Cheers,
Ryan

ho nice, I totally missed those.
Great resource