Ejemplo n.º 1
0
    def _write_interpreter_file(self,
                                executable=sys.executable,
                                prefix=sys.prefix):
        """
        Writes the interpreter file to disk based on an executable and prefix.

        :returns: Path that was written in each interpreter file.
        :rtype: sgtk.util.ShotgunPath
        """
        core_folder = os.path.join(self._root, "config", "core")
        if not os.path.exists(core_folder):
            os.makedirs(core_folder)
        os.makedirs(
            os.path.join(self._root, "install", "core", "setup",
                         "root_binaries"))

        self._cw.create_tank_command(executable, prefix)

        interpreters = []
        for platform in ["Windows", "Linux", "Darwin"]:
            file_name = os.path.join(self._root, "config", "core",
                                     "interpreter_%s.cfg" % platform)

            with open(file_name, "r") as w:
                interpreters.append(w.read())

        return ShotgunPath(*interpreters)
Ejemplo n.º 2
0
    def test_configuration_not_found_on_disk(self):
        """
        Ensure that the resolver detects when an installed configuration is not available for the
        current platform.
        """
        this_path_does_not_exists = "/this/does/not/exists/on/disk"
        pc_id = self._create_pc(
            "Primary",
            None,
            this_path_does_not_exists
        )["id"]

        expected_descriptor_dict = ShotgunPath(
            this_path_does_not_exists, this_path_does_not_exists, this_path_does_not_exists
        ).as_shotgun_dict()
        expected_descriptor_dict["type"] = "path"

        with self.assertRaisesRegexp(
            sgtk.bootstrap.TankBootstrapError,
            "Installed pipeline configuration '.*' does not exist on disk!"
        ):
            self.resolver.resolve_shotgun_configuration(
                pc_id,
                [],
                self.mockgun,
                "john.smith"
            )
Ejemplo n.º 3
0
    def setUp(self):
        """
        Prepare unit test.
        """
        super(TestSetupProjectWizard, self).setUp(
            parameters={"primary_root_name": "primary"}
        )
        self._wizard = sgtk.get_command("setup_project_factory").execute({})

        self._storage_locations = ShotgunPath(
            "Z:\\projects", "/mnt/projects", "/Volumes/projects"
        )
        self._storage_locations.current_os = self.tank_temp

        self.mockgun.update(
            "LocalStorage",
            self.primary_storage["id"],
            self._storage_locations.as_shotgun_dict(),
        )

        # Prepare the wizard for business. All these methods are actually passing
        # information directly to the SetupProjectParams object inside
        # the wizard, so there's no need to test them per-se.
        self._wizard.set_project(self.project["id"], force=True)
        self._wizard.set_use_distributed_mode()

        self.config_uri = os.path.join(self.fixtures_root, "config")
        self._wizard.set_config_uri(self.config_uri)
Ejemplo n.º 4
0
 def _get_default_intepreters(self):
     """
     Gets the default interpreter values for the Shotgun Desktop.
     """
     return ShotgunPath(
         r"C:\Program Files\Shotgun\Python\python.exe",
         "/opt/Shotgun/Python/bin/python",
         "/Applications/Shotgun.app/Contents/Resources/Python/bin/python")
    def test_character_escaping(self):
        """
        Ensure that the ' characte is properly escaped
        when writing out install_location.yml
        """
        new_config_root = os.path.join(self.tank_temp, self.short_test_name,
                                       "O'Connell")

        writer = ConfigurationWriter(
            ShotgunPath.from_current_os_path(new_config_root), self.mockgun)

        install_location_path = os.path.join(new_config_root, "config", "core",
                                             "install_location.yml")

        os.makedirs(os.path.dirname(install_location_path))

        writer.write_install_location_file()

        with open(install_location_path, "rt") as f:
            paths = yaml.safe_load(f)
            path = ShotgunPath(paths["Windows"], paths["Linux"],
                               paths["Darwin"])
        assert path.current_os == new_config_root