Beispiel #1
0
    def _extract_products_from_path(self, executable_path, match):
        """
        Extracts the products from an executable. Note that more than one product
        can be extracted from a single executable on certain platforms.

        :param str executable_path: Path to the executable.
        :param match: Tokens that were extracted from the executable.

        :returns: Generator that generates each product that can be launched from the given
            executable.
        """
        executable_version = match.get("version")
        if sys.platform == "darwin":
            # Extract the product from the file path, as each product of the product has an actual
            # executable associated to it.

            # extract the components (default to None if not included)
            executable_product = match.get("product")
            # If there is no suffix (Non-commercial or PLE), we'll simply use an empty string).
            executable_suffix = match.get("suffix") or ""

            # Generate the display name.
            product = "%s%s" % (executable_product, executable_suffix)

            yield SoftwareVersion(
                executable_version,
                product,
                executable_path,
                self._get_icon_from_product(executable_product),
            )
        else:
            for product in self._get_products_from_version(executable_version):
                # Figure out the arguments required for each product.
                arguments = []
                if "Studio" in product:
                    arguments.append("--studio")
                elif "Assist" in product:
                    arguments.append("--nukeassist")
                elif "NukeX" in product:
                    arguments.append("--nukex")
                elif "Hiero" in product:
                    arguments.append("--hiero")

                sw = SoftwareVersion(
                    executable_version,
                    product,
                    executable_path,
                    self._get_icon_from_product(product),
                    arguments,
                )
                yield sw
Beispiel #2
0
    def _find_software(self):
        """
        Find executables in the Registry for Windows
        :returns: List of :class:`SoftwareVersion` instances
        """
        sw_versions = []
        if is_windows():
            # Determine a list of paths to search for VRED executables based
            # on the windows registry
            install_paths_dicts = _get_installation_paths_from_windows_registry(
                self.logger)

            for install_paths in install_paths_dicts:
                executable_version = self._map_version_year(
                    install_paths["version"])
                executable_path = install_paths["path"]
                launcher_name = install_paths["_name"]
                icon_file = self._icon_from_executable(launcher_name)

                # Create The actual SoftwareVersions
                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        launcher_name,
                        executable_path,
                        icon_file,
                    ))

        return sw_versions
Beispiel #3
0
    def scan_software(self):
        """
        Scan the filesystem for natron executables.

        :return: A list of :class:`SoftwareVersion` objects.
        """

        try:
            import rez as _
        except ImportError:
            rez_path = self.get_rez_module_root()
            if not rez_path:
                raise EnvironmentError(
                    'rez is not installed and could not be automatically found. Cannot continue.'
                )

            sys.path.append(rez_path)
        from rez.package_search import ResourceSearcher, ResourceSearchResultFormatter

        searcher = ResourceSearcher()
        formatter = ResourceSearchResultFormatter()
        _, packages = searcher.search("3de")

        supported_sw_versions = []
        self.logger.debug("Scanning for 3de executables...")
        infos = formatter.format_search_results(packages)

        for info in infos:
            name, version = info[0].split("-")

            software = SoftwareVersion(version, name, "rez_init",
                                       self._icon_from_engine())
            supported_sw_versions.append(software)

        return supported_sw_versions
    def _find_software(self):
        """
        Find executables in the default install locations.
        """
        template = os.path.join(config.REZ_PACKAGE_ROOT, 'maya', '{version}')

        self.logger.debug("Processing template %s.", template)
        self.logger.debug('I AM HERE')

        executable_matches = self._glob_and_match(template,
                                                  self.COMPONENT_REGEX_LOOKUP)

        # all the discovered executables
        sw_versions = []

        # Extract all products from that executable.
        for (executable_path, key_dict) in executable_matches:

            # extract the matched keys form the key_dict (default to None if
            # not included)
            executable_version = key_dict.get("version")

            sw_versions.append(
                SoftwareVersion(executable_version, "Maya", executable_path,
                                self._icon_from_executable(executable_path)))

        return sw_versions
Beispiel #5
0
    def scan_software(self):

        try:
            import rez as _
        except ImportError:
            rez_path = self.get_rez_module_root()
            if not rez_path:
                raise EnvironmentError(
                    'rez is not installed and could not be automatically found. Cannot continue.'
                )

            sys.path.append(rez_path)
        from rez.package_search import ResourceSearcher, ResourceSearchResultFormatter

        searcher = ResourceSearcher()
        formatter = ResourceSearchResultFormatter()
        _, packages = searcher.search("katana")

        supported_sw_versions = []
        self.logger.debug("Scanning for katana executables...")
        infos = formatter.format_search_results(packages)
        for info in infos:
            name, version = info[0].split("-")

            software = SoftwareVersion(version, name, "rez_init",
                                       self._icon_from_engine())

            (supported, reason) = self._is_supported(software)
            if supported:
                if self.check_software(software):
                    supported_sw_versions.append(software)

        return supported_sw_versions
Beispiel #6
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(sys.platform, [])

        # all the discovered executables
        sw_versions = []

        for executable_template in executable_templates:

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict (default to None if
                # not included)
                executable_version = key_dict.get("version")

                sw_versions.append(
                    SoftwareVersion(
                        executable_version, "Maya", executable_path,
                        self._icon_from_executable(executable_path)))

        return sw_versions
    def _find_software(self):
        # use the bundled engine icon
        icon_path = os.path.join(
            self.disk_location,
            'icon_256.png'
        )

        self.logger.debug('Using icon path "%s".', icon_path)

        template = os.path.join(config.REZ_PACKAGE_ROOT, 'houdini', '{version}')

        self.logger.debug("Processing template %s.", template)

        products = set(self.EXECUTABLE_TO_PRODUCT.values())

        for executable, tokens in self._glob_and_match(template, self.COMPONENT_REGEX_LOOKUP):
            self.logger.debug('Processing "%s" with tokens "%s".', executable, tokens)

            # extract the matched keys form the key_dict (default to None if
            # not included)
            executable_version = tokens.get('version')

            for product in products:
                yield SoftwareVersion(
                    executable_version,
                    product,
                    '',  # We don't need to provide an executable path. Rez will do it for us
                    icon_path
                )
Beispiel #8
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(
            "darwin" if sgtk.util.is_macos() else "win32" if sgtk.util.
            is_windows() else "linux" if sgtk.util.is_linux() else [])

        # all the discovered executables
        found = False
        sw_versions = []

        for executable_template in executable_templates:
            self.logger.debug("PreProcessing template %s.",
                              executable_template)
            executable_template = os.path.expanduser(executable_template)
            executable_template = os.path.expandvars(executable_template)

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:
                # extract the matched keys form the key_dict (default to None
                # if not included)
                self.logger.debug(
                    "Processing executable_path: %s | dict %s",
                    executable_path,
                    key_dict,
                )

                # no way to extract the version from this application, so no
                # version is available to display
                executable_version = " "

                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        APPLICATION_NAME,
                        executable_path,
                        self._icon_from_engine(),
                    ))
                # TBR DGH060520
                # break here if you found one executable, at least until we
                # find a way to track different versions of Krita.
                # Note that kritarunner is one of them but way too convoluted
                # for what is really worth. I welcome other ideas!
                found = True
                break

            if found:
                break

        return sw_versions
Beispiel #9
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(
            "darwin"
            if sgtk.util.is_macos()
            else "win32"
            if sgtk.util.is_windows()
            else "linux"
            if sgtk.util.is_linux()
            else []
        )

        # all the discovered executables
        sw_versions = []

        # Here we account for extra arguments passed to the blender command line
        # this allows a bit of flexibility without having to fork the whole
        # engine just for this reason.
        # Unfortunately this cannot be put in the engine.yml as I would like
        # to because the engine class has not even been instantiated yet.
        extra_args = os.environ.get("SGTK_RUMBA_CMD_EXTRA_ARGS")

        for executable_template in executable_templates:
            executable_template = os.path.expanduser(executable_template)
            executable_template = os.path.expandvars(executable_template)

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP
            )

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:
                # no way to extract the version from this application, so no
                # version is available to display
                executable_version = " "

                args = []
                if extra_args:
                    args.append(extra_args)

                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        APPLICATION_NAME,
                        executable_path,
                        icon=self._icon_from_engine(),
                        args=args,
                    )
                )

        return sw_versions
Beispiel #10
0
    def _find_software(self):
        """
        Find installed UE executable.

        :returns: List of :class:`SoftwareVersion` instances.
        :raises RuntimeError: For unsupported OSes.
        """
        self.logger.info("Finding Unreal Engine executables")
        sw_versions = []

        # Get the executable templates for the current OS
        executable_templates = None
        if sgtk.util.is_macos():
            executable_templates = self.EXECUTABLE_TEMPLATES.get("darwin")
        elif sgtk.util.is_windows():
            executable_templates = self.EXECUTABLE_TEMPLATES.get("win32")
        elif sgtk.util.is_linux():
            executable_templates = self.EXECUTABLE_TEMPLATES.get("linux")

        if not executable_templates:
            raise RuntimeError("Unsupported platform %s" % sys.platform)

        for executable_template in executable_templates:
            self.logger.debug("Processing template %s.", executable_template)
            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)
            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:
                # extract the matched keys form the key_dict (default to None if
                # not included)
                executable_version = key_dict.get("version")
                details = self._get_unreal_version_details(executable_path)
                if details and all(
                        x in details for x in
                    ["MajorVersion", "MinorVersion", "PatchVersion"]):
                    executable_version = "%s.%s.%s" % (
                        details["MajorVersion"],
                        details["MinorVersion"],
                        details["PatchVersion"],
                    )
                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        "Unreal Engine",
                        executable_path,
                        os.path.join(self.disk_location, "icon_256.png"),
                    ))
        if sgtk.util.is_windows():
            # On Windows we also explore registry, but make sure to not add
            # things twice.
            found_paths = [sw.path for sw in sw_versions]
            for sw in self._find_software_from_registry():
                if sw.path not in found_paths:
                    sw_versions.append(sw)
                    found_paths.append(sw.path)

        return sw_versions
Beispiel #11
0
    def _find_software(self):

        # use the bundled engine icon
        icon_path = os.path.join(self.disk_location, "icon_256.png")
        self.logger.debug("Using icon path: %s" % (icon_path, ))

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(
            "darwin" if sgtk.util.is_macos() else "win32" if sgtk.util.
            is_windows() else "linux2" if sgtk.util.is_linux() else [])

        # all the discovered executables
        sw_versions = []

        for executable_template in executable_templates:

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict (default to None if
                # not included)
                executable_version = key_dict.get("version")
                executable_product = key_dict.get("product")
                executable_name = key_dict.get("executable")

                # we need a product to match against. If that isn't provided,
                # then an executable name should be available. We can map that
                # to the proper product.
                if not executable_product:
                    executable_product = self.EXECUTABLE_TO_PRODUCT.get(
                        executable_name)

                # only include the products that are covered in the EXECUTABLE_TO_PRODUCT dict
                if (executable_product is None or executable_product
                        not in self.EXECUTABLE_TO_PRODUCT.values()):
                    self.logger.debug(
                        "Product '%s' is unrecognized. Skipping." %
                        (executable_product, ))
                    continue

                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        executable_product,
                        executable_path,
                        icon_path,
                    ))

        return sw_versions
Beispiel #12
0
    def _find_software(self):
        """
        Find executables in the Windows Registry.

        :returns: List of :class:`SoftwareVersion` instances
        """
        # Determine a list of paths to search for 3dsMax executables based
        # on the windows registry
        search_paths = _get_installation_paths_from_registry(self.logger)
        exec_paths = []

        for search_path in search_paths:
            # Construct the expected executable name for this path.
            # If it exists, add it to the list of exec_paths to check.
            exec_path = os.path.join(search_path, "3dsmax.exe")

            if os.path.exists(exec_path):
                self.logger.debug(
                    "found version in default installation path %s" %
                    exec_path)
                exec_paths.append(exec_path)

        sw_versions = []
        for exec_path in exec_paths:
            # Check to see if the version number can be parsed from the path name.
            path_sw_versions = [
                p.lower() for p in exec_path.split(os.path.sep)
                if re.match("3ds max [0-9]+[.0-9]*$", p.lower()) is not None
            ]
            if path_sw_versions:
                # Use this sub dir to determine the default display name
                # and version for the SoftwareVersion to be created.
                executable_version = path_sw_versions[0].replace(
                    "3ds max ", "")
                self.logger.debug(
                    "Resolved version '%s' from executable '%s'." %
                    (executable_version, exec_path))

            # Create a SoftwareVersion using the information from executable
            # path(s) found in default locations.
            self.logger.debug("Creating SoftwareVersion for executable '%s'." %
                              exec_path)
            sw_versions.append(
                SoftwareVersion(
                    executable_version,
                    "3ds Max",
                    exec_path,
                    os.path.join(self.disk_location, "icon_256.png"),
                ))

        return sw_versions
Beispiel #13
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(sys.platform, [])

        # all the discovered executables
        sw_versions = []

        # Here we account for extra arguments passed to the blender command line
        # this allows a bit of flexibility without having to fork the whole
        # engine just for this reason.
        # Unfortunately this cannot be put in the engine.yml as I would like
        # to because the engine class has not even been instantiated yet.
        extra_args = os.environ.get("SGTK_BLENDER_CMD_EXTRA_ARGS")

        for executable_template in executable_templates:
            executable_template = os.path.expanduser(executable_template)
            executable_template = os.path.expandvars(executable_template)

            self.logger.debug("Processing template %s", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict.
                # in the case of version we return something different than
                # an empty string because there are cases were the installation
                # directories do not include version number information.
                executable_version = key_dict.get("version", " ")

                args = []
                if extra_args:
                    args.append(extra_args)

                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        "Blender",
                        executable_path,
                        icon=self._icon_from_engine(),
                        args=args,
                    ))

        return sw_versions
Beispiel #14
0
    def scan_software(self):
        """
        Scan the filesystem for all After Effects executables.

        :return: A list of :class:`SoftwareVersion` objects.
        """

        self.logger.debug("Scanning for After Effects executables...")

        # use the bundled icon
        icon_path = os.path.join(self.disk_location, "icon_256.png")
        self.logger.debug("Using icon path: %s" % (icon_path,))

        platform = (
            "win32"
            if sgtk.util.is_windows()
            else "darwin"
            if sgtk.util.is_macos()
            else None
        )

        if platform is None:
            self.logger.debug("After Effects not supported on this platform.")
            return []

        all_sw_versions = []

        for match_template_set in self.EXECUTABLE_MATCH_TEMPLATES:
            for executable_path, tokens in self._glob_and_match(
                match_template_set[platform], self.COMPONENT_REGEX_LOOKUP
            ):
                self.logger.debug(
                    "Processing %s with tokens %s", executable_path, tokens
                )
                # extract the components (default to None if not included). but
                # version is in all templates, so should be there.
                executable_version = tokens.get("version")

                sw_version = SoftwareVersion(
                    executable_version, "After Effects CC", executable_path, icon_path
                )
                supported, reason = self._is_supported(sw_version)
                if supported:
                    all_sw_versions.append(sw_version)
                else:
                    self.logger.debug(reason)

        return all_sw_versions
Beispiel #15
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(sys.platform, [])

        # all the discovered executables
        sw_versions = []

        for executable_template in executable_templates:

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict (default to None
                # if not included)
                if sys.platform == "win32":
                    executable_version = get_file_info(executable_path,
                                                       "FileVersion")
                    # make sure we remove those pesky \x00 characters
                    executable_version = executable_version.strip("\x00")
                else:
                    executable_version = key_dict.get("version", "2018.0.0")

                self.logger.debug(
                    "Software found: %s | %s.",
                    executable_version,
                    executable_template,
                )
                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        "Substance Painter",
                        executable_path,
                        self._icon_from_engine(),
                    ))

        return sw_versions
Beispiel #16
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(sys.platform, [])

        # all the discovered executables
        sw_versions = []

        for executable_template in executable_templates:
            executable_template = os.path.expanduser(executable_template)
            executable_template = os.path.expandvars(executable_template)

            self.logger.debug("Processing template %s", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP
            )

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict.
                # in the case of version we return something different than
                # an empty string because there are cases were the installation
                # directories do not include version number information.
                executable_version = key_dict.get("version", " ")
                if "minor" in key_dict:
                    executable_version += key_dict["minor"]
                if "service_pack" in key_dict:
                    executable_version += " " + key_dict["service_pack"]

                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        "Clarisse",
                        executable_path,
                        self._icon_from_engine(),
                    )
                )

        return sw_versions
Beispiel #17
0
    def scan_software(self):
        """
        Performs a scan for software installations.

        :param list versions: List of strings representing versions
                              to search for. If set to None, search
                              for all versions. A version string is
                              DCC-specific but could be something
                              like "2017", "6.3v7" or "1.2.3.52".
        :returns: List of :class:`SoftwareVersion` instances
        """
        sw_versions = []
        for version in range(0, 10):
            sw_path = "/path/to/unit/test/app/%s/executable"
            sw_icon = "%s/icons/exec.png" % os.path.dirname(sw_path)
            sw_versions.append(
                SoftwareVersion(version, "Unit Test App", sw_path, sw_icon)  # product
            )
        return sw_versions
Beispiel #18
0
    def _get_software_from_search_paths(self, search_paths, display_name):
        sw_versions = []
        for search_path in search_paths:
            # Construct the expected executable name for this path.
            # If it exists, add it to the list of exec_paths to check.
            exec_path, executable_version = self._find_exec_and_version(search_path)

            if exec_path:
                # Create a SoftwareVersion using the information from executable
                # path(s) found in default locations.
                self.logger.debug("Creating SoftwareVersion for executable '%s'." % exec_path)
                sw_versions.append(SoftwareVersion(
                    executable_version,
                    display_name,
                    exec_path,
                    os.path.join(self.disk_location, "icon_256.png")
                ))
        
        return sw_versions
Beispiel #19
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(
            "darwin" if sgtk.util.is_macos() else "win32" if sgtk.util.
            is_windows() else "linux" if sgtk.util.is_linux() else [])

        # all the discovered executables
        sw_versions = []

        for executable_template in executable_templates:

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict (default to None
                # if not included)
                executable_version = key_dict.get("version", None)
                executable_edition = key_dict.get("edition00", "")
                self.logger.debug("Software found: %s | %s.",
                                  executable_version, executable_template)
                icon_path = self._icon_from_software_path(
                    executable_path, executable_edition)
                if not icon_path:
                    icon_path = self._icon_from_engine()

                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        "Harmony %s" % executable_edition,
                        executable_path,
                        icon_path,
                    ))

        return sw_versions
Beispiel #20
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        platform_os = platform.system()
        executable_templates = self.EXECUTABLE_TEMPLATES.get(platform_os, [])

        # all the discovered executables
        sw_versions = []

        for executable_template in executable_templates:

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP
            )

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict (default to None
                # if not included)
                executable_version = key_dict.get("version", None)
                executable_edition = key_dict.get("edition", "")
                self.logger.debug(
                    "Software found: %s | %s.",
                    executable_version,
                    executable_template,
                )
                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        "Harmony %s" % executable_edition,
                        executable_path,
                        self._icon_from_engine(),
                    )
                )

        return sw_versions
Beispiel #21
0
    def scan_software(self):
        """
        For each software executable that was found, get the software products for it.

        :returns: List of :class:`SoftwareVersion`.
        """

        # A list of software scan results can be provided via the SHOTGUN_SCAN_SOFTWARE_LIST env var
        # as a serialized string containing a list of SoftwareVersion instances.

        serialized_software_list = os.environ.get("SHOTGUN_SCAN_SOFTWARE_LIST")
        if serialized_software_list:
            software_list = pickle.loads(serialized_software_list)
        else:
            # No scanned software was provided so provide a single default software.
            software_list = [
                SoftwareVersion("2020", "Test Software",
                                "path/to/software_2020.app", "", [])
            ]
        return software_list
Beispiel #22
0
    def _find_software_from_registry(self):
        """
        Find executables in the Windows Registry.

        :returns: List of :class:`SoftwareVersion` instances.
        """
        self.logger.info("Detecting Unreal Engine from registry...")
        try:
            # Note: keeping this as is, without knowing why it was implemented
            # like that, instead of just doing import winreg
            import _winreg
        except ImportError:
            import winreg as _winreg

        self.logger.debug(
            "Querying windows registry for key HKEY_LOCAL_MACHINE\\SOFTWARE\\EpicGames\\Unreal Engine"
        )
        base_key_name = "SOFTWARE\\EpicGames\\Unreal Engine"
        # find all subkeys in key HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine
        sw_versions = []
        try:
            key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, base_key_name)
            sub_key_count = _winreg.QueryInfoKey(key)[0]
            for i in range(sub_key_count):
                sub_key_name = _winreg.EnumKey(key, i)
                sub_key = _winreg.OpenKey(key, sub_key_name)
                values_count = _winreg.QueryInfoKey(sub_key)[1]
                if sub_key_name == "Builds":
                    for j in range(values_count):
                        value = _winreg.EnumValue(sub_key, j)[1]
                        self.logger.info("Checking %s" % value)
                        if value and os.path.exists(value):
                            executable_path = self._get_win_executable_path(
                                value)
                            if executable_path:
                                sw = SoftwareVersion(
                                    self._get_unreal_version(executable_path),
                                    "Unreal Engine (Dev Build)",
                                    executable_path,
                                    os.path.join(self.disk_location,
                                                 "icon_256.png"))
                                sw_versions.append(sw)
                else:
                    for j in range(values_count):
                        value_name, value, _ = _winreg.EnumValue(sub_key, j)
                        if value_name == "InstalledDirectory":
                            if value and os.path.exists(value):
                                executable_path = self._get_win_executable_path(
                                    value)
                                if executable_path:
                                    sw = SoftwareVersion(
                                        self._get_unreal_version(
                                            executable_path), "Unreal Engine",
                                        executable_path,
                                        os.path.join(self.disk_location,
                                                     "icon_256.png"))
                                    sw_versions.append(sw)

                            break
            _winreg.CloseKey(key)
        except WindowsError as e:
            self.logger.error("Error handling key %s: %s" % (base_key_name, e))
            # Log the traceback in debug
            self.logger.debug("Error opening key %s: %s" % (base_key_name, e),
                              exc_info=True)

        return sw_versions
    def _create_software(self):
        """
        This will be called by the setup just before the engine is started, to allow creation of Software entities.
        """
        # additional custom args
        self._additional_args = "--test"
        # Create a Software entity with no paths provided so that it doesn't automatically scan for software.

        # Create one Software entity where the path is provided and one where it isn't.
        # This will test manual and automatic software path finding.

        def register_software(name, path=None, description=None):
            return self.mockgun.create(
                "Software",
                {
                    "code": name,
                    "engine": "tk-testengine",
                    "image": None,
                    "version_names": None,
                    "products": None,
                    "group_name": None,
                    "group_default": False,
                    "linux_path": path,
                    "mac_path": path,
                    "windows_path": path,
                    "linux_args": self._additional_args,
                    "mac_args": self._additional_args,
                    "windows_args": self._additional_args,
                    "description": description,
                    # This isn't a standard field that the launch app would normally request, but
                    # we are testing that the `software_entity_extra_fields` setting which is set to include
                    # the created_at field in the fixtures will actually fetch the field.
                    "created_at": datetime.datetime.now(),
                },
            )

        # Manual and Auto path SW entities
        self._manual_software_entity = register_software(
            "manual", "/path/to/software", "manual paths"
        )
        self._auto_software_entity = register_software("auto", description="auto paths")
        # No description entity, use a path so that we can have command name registered
        self._no_desc_software_entity = register_software(
            "no description", "/path/to/software"
        )

        # Provide the scan results to the tk-testengine startup scan software method via an environment variable.
        # We json serialize a list of lists. Each sub list must contain a value for the SoftwareEntity initialization
        # parameters in the following order: version, product, path, icon, args

        # These represent the standard args a specific engine might add to the list of launch args.
        self._engine_args = ["--engine --engine2"]
        scanned_software = [
            SoftwareVersion(
                "2020",
                "Auto",  # For auto path SW entities this becomes part of the command name + the version/year
                "path/to/software_2020.app",
                "",
                self._engine_args,
            )
        ]

        os.environ["SHOTGUN_SCAN_SOFTWARE_LIST"] = pickle.dumps(scanned_software)
Beispiel #24
0
    def _find_software(self):

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(sys.platform, [])
        executable_regexp = self.COMPONENT_REGEX_LOOKUP.get(sys.platform, [])

        # all the discovered executables
        sw_versions = []

        for executable_template in executable_templates:

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(executable_template,
                                                      executable_regexp)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict (default to None if
                # not included)
                executable_version = key_dict.get("version")
                executable_product = key_dict.get("product")
                executable_name = key_dict.get("executable")
                executable_app = key_dict.get("app")

                # we need a product to match against. If that isn't provided,
                # then an executable name should be available. We can map that
                # to the proper product.
                if not executable_product:
                    executable_product = \
                        self.EXECUTABLE_TO_PRODUCT.get(executable_name)

                # Unknown product
                if not executable_product:
                    continue

                # Adapt the FlameAssist product name
                if executable_product == "FlameAssist":
                    executable_product = "Flame Assist"

                # only include the products that are covered in the EXECUTABLE_TO_PRODUCT dict
                if not executable_product.startswith(
                        "Flame") and not executable_product.startswith(
                            "Flare"):
                    self.logger.debug(
                        "Product '%s' is unrecognized. Skipping." %
                        (executable_product, ))
                    continue

                # exclude Technology demo apps
                if executable_app and "Technology Demo" in executable_app:
                    self.logger.debug("Ignoring '%s %s - %s'" %
                                      (executable_product, executable_version,
                                       executable_app))
                    continue

                # figure out which icon to use
                icon_path = os.path.join(
                    self.disk_location,
                    self.ICON_LOOKUP.get(executable_product,
                                         self.ICON_LOOKUP["Flame"]))
                self.logger.debug("Using icon path: %s" % (icon_path, ))

                sw_versions.append(
                    SoftwareVersion(executable_version, executable_product,
                                    executable_path, icon_path))

        return sw_versions
Beispiel #25
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        """

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(
            "darwin" if sgtk.util.is_macos() else "win32" if sgtk.util.
            is_windows() else "linux" if sgtk.util.is_linux() else [])

        # all the discovered executables
        found = False
        sw_versions = []

        for executable_template in executable_templates:
            self.logger.debug("PreProcessing template %s.",
                              executable_template)
            executable_template = os.path.expanduser(executable_template)
            executable_template = os.path.expandvars(executable_template)

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:
                # extract the matched keys form the key_dict (default to None
                # if not included)
                self.logger.debug(
                    "Processing executable_path: %s | dict %s",
                    executable_path,
                    key_dict,
                )

                if sgtk.util.is_windows():
                    executable_version = get_file_info(executable_path,
                                                       "FileVersion")
                    # make sure we remove those pesky \x00 characters
                    executable_version = executable_version.strip("\x00")
                else:
                    # no way to extract the version from this application, so no
                    # version is available to display
                    executable_version = " "

                sw_versions.append(
                    SoftwareVersion(
                        executable_version,
                        APPLICATION_NAME,
                        executable_path,
                        self._icon_from_engine(),
                    ))
                # TBR DGH010720
                # break here if you found one executable, at least until we
                # find a way to track different versions of Substance Designer.
                found = True
                break

            if found:
                break

        return sw_versions
Beispiel #26
0
    def _find_software(self):
        """
        Find executables in the default install locations.
        
        Three different ways to find versions:
            1. If Unity Hub is installed, get versions from editors.json file
            2. Use default install location templates to glob for executable filesystem
            3. Try to get paths from UNITY_EDITOR_PATH environment variable if set
        """

        # all the discovered executables
        sw_versions = []

        # If Unity Hub is installed then try to get some of the versions from there
        editor_jsons = self.HUB_EXECUTABLES.get(sys.platform, [])
        username = getpass.getuser()
        for editor_json in [j.format(username=username) for j in editor_jsons]:
            if os.path.exists(editor_json):
                with open(editor_json, "r") as f:
                    data = json.load(f)
                    if not data:
                        continue

                    for vals in data.values():
                        version = vals["version"]
                        exec_paths = vals["location"]  # list of locations
                        if len(exec_paths) < 1:
                            continue
                        exec_path = exec_paths[0]

                        sw_versions.append(
                            SoftwareVersion(
                                version, "Unity", exec_path,
                                os.path.join(self.disk_location,
                                             "icon_256.png")))

        # all the executable templates for the current OS
        executable_templates = self.EXECUTABLE_TEMPLATES.get(sys.platform, [])

        for executable_template in executable_templates:

            self.logger.debug("Processing template %s.", executable_template)

            executable_matches = self._glob_and_match(
                executable_template, self.COMPONENT_REGEX_LOOKUP)

            # Extract all products from that executable.
            for (executable_path, key_dict) in executable_matches:

                # extract the matched keys form the key_dict (default to None if
                # not included)
                executable_version = key_dict.get("version", "Unknown")

                self.logger.debug("Software was found: " + executable_path +
                                  ", " + executable_version)

                sw_versions.append(
                    SoftwareVersion(
                        executable_version, "Unity", executable_path,
                        os.path.join(self.disk_location, "icon_256.png")))

        # also try to get from environment variable
        environ_paths = os.environ.get("UNITY_EDITOR_PATH")
        if not environ_paths:
            return sw_versions

        environ_paths = environ_paths.split(";")
        for executable_path in environ_paths:
            sw_versions.append(
                SoftwareVersion(
                    "Unknown", "Unity", executable_path,
                    os.path.join(self.disk_location, "icon_256.png")))

        return sw_versions