AWS Thinkbox Discussion Forums

See plugin version in slaves list

Hi there, is there any way of seeing the plugin version in the slaves list? We can see what plugin a slave is using but really could do with also seeing the version number.

I assume you mean a plugin to an application like Maya, or C4D and not a plugin as in “3dsmax” in the “plugins” folder.

We have two (Windows only) event examples for this:

Thanks… that is exactly what i am looking for. I am not familiar with adding in custom scripts to Deadline, is it just a matter of alterring the param file and then copying the 3 files into the repository custom folder?

Got it working using the 3dsMaxVersionInstalled event published on the same page on Github. Now trying the softwareAudit for plugin version detection, which is not quite working… will keep testing

Me again… all good, works well. I was wondering how easy it would be to create an event plugin that takes any windows registry key path and returns the value in the Extra info X slave list entry?

1 Like

It’s not hard, but it requires testing. You can dabble with the code, it’s safe (it won’t burn your Slaves down). Just play around with the ExtraInfoX and the registry key name and see what comes of it.

Something like this?

'''
    Show what copy of a particular piece of software is installed on your
    Windows nodes in the 'Extra Info 0-5' column.
'''

from System.Diagnostics import *
from System.IO import *
from System import TimeSpan

from Deadline.Events import *
from Deadline.Scripting import *

import _winreg
import time
import os


def GetDeadlineEventListener():
    return ConfigSlaveEventListener()


def CleanupDeadlineEventListener(eventListener):
    eventListener.Cleanup()


class ConfigSlaveEventListener (DeadlineEventListener):
    def __init__(self):
        self.OnSlaveStartedCallback += self.OnSlaveStarted

    def Cleanup(self):
        del self.OnSlaveStartedCallback

    # This is called every time the Slave starts
    def OnSlaveStarted(self, slavename):
        if os.name == "nt":
            title = self.GetConfigEntry("Software Title")
            if ";" in title:
                title = title.split(";")
                slave = RepositoryUtils.GetSlaveSettings(slavename, True)
                for n in range(0, len(title)):
                    if n == 0:
                        slave.SlaveExtraInfo1 = self.GetVersion(title[n])
                    elif n == 1:
                        slave.SlaveExtraInfo2 = self.GetVersion(title[n])
                    elif n == 2:
                        slave.SlaveExtraInfo3 = self.GetVersion(title[n])
                    elif n == 3:
                        slave.SlaveExtraInfo4 = self.GetVersion(title[n])
                    elif n == 4:
                        slave.SlaveExtraInfo5 = self.GetVersion(title[n])
            else:
                slave = RepositoryUtils.GetSlaveSettings(slavename, True)
                slave.SlaveExtraInfo1 = self.GetVersion(title)
            time.sleep(2)
            RepositoryUtils.SaveSlaveSettings(slave)
        else:
            print "Not windows slave."
            return

    def GetVersion(self, software_title):
        versions = []
        try:
            i = 0
            explorer = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall'
            )

            while True:
                key = _winreg.EnumKey(explorer, i)
                if software_title in key and "Populate Data" not in key:
                    print('Found "{0}" in the list of installed software'.format(key))
                    try:
                        item = _winreg.OpenKey(explorer, key)
                        version, type = _winreg.QueryValueEx(item, 'DisplayVersion')
                        print(' Its version was {0}'.format(version))
                        _winreg.CloseKey(item)

                        #_winreg.CloseKey(explorer)
                        #return version
                        if version not in versions:
                            versions.append(version)
                    except:
                        print"No DisplayVersion key found. Trying DisplayName."
                        try:
                            item = _winreg.OpenKey(explorer, key)
                            version, type = _winreg.QueryValueEx(item, 'DisplayName')
                            print(' Its version was {0}'.format(version))
                            _winreg.CloseKey(item)

                            #_winreg.CloseKey(explorer)
                            #return version
                            if version not in versions:
                                versions.append(version)
                        except:
                            _winreg.CloseKey(item)
                            print"No DisplayName key found."
                        _winreg.CloseKey(item)
                        
                i += 1

        except WindowsError as e:
            print(e)

        _winreg.CloseKey(explorer)
        InstalledVersions = ""
        try:
            if versions[0] != "":
                for t in versions :
                    print t
                    if InstalledVersions == "":
                        InstalledVersions = t
                    else:
                        InstalledVersions = InstalledVersions + ", " + t
                return InstalledVersions
            else:
                return "unknown"
        except:
            return "unknown"

And the .param file

[State]
Type=Enum
Items=Global Enabled;Opt-In;Disabled
Category=Options
CategoryOrder=0
Index=0
Label=State
Default=Global Enabled
Description=If this event plugin is enabled.

[Software Title]
Type=string
Category=Configuration
CategoryOrder=1
Index=0
Label=Software Title
Default=V-Ray for 3dsmax 2014 for x64
Description=Which software titles whose version we should report. As seen in the 'Add/remove programs' list. Separated by ;

Ooo! This looks good! I haven’t tested it yet but seems solid.

There are a few code design bits that could be cleaned up but I think it’ll work nicely up to five products and fail gracefully after that. I’m a bit concerned how we break out of “while True” there, but that’s Past Edwin’s fault.

Privacy | Site terms | Cookie preferences