def test_installed_configuration_not_on_disk(self): """ Ensure that the resolver detects when an installed configuration has not been set for the current platform. """ # Create a pipeline configuration. pc_id = self._create_pc( "Primary", self._project, "sg_path", plugin_ids="foo.*", )["id"] # Remove the current platform's path. self.mockgun.update("PipelineConfiguration", pc_id, {ShotgunPath.get_shotgun_storage_key(): None}) with self.assertRaisesRegexp( sgtk.bootstrap.TankBootstrapError, "The Shotgun pipeline configuration with id %s has no source location specified for " "your operating system." % pc_id): self.resolver.resolve_shotgun_configuration( pipeline_config_identifier=pc_id, fallback_config_descriptor=self.config_1, sg_connection=self.mockgun, current_login="******")
def test_installed_configuration_not_on_disk(self): """ Ensure that the resolver detects when an installed configuration has not been set for the current platform. """ # Create a pipeline configuration. pc_id = self._create_pc( "Primary", self._project, "sg_path", plugin_ids="foo.*", )["id"] # Remove the current platform's path. self.mockgun.update( "PipelineConfiguration", pc_id, { ShotgunPath.get_shotgun_storage_key(): None } ) with self.assertRaisesRegex( sgtk.bootstrap.TankBootstrapError, "The Shotgun pipeline configuration with id %s has no source location specified for " "your operating system." % pc_id ): self.resolver.resolve_shotgun_configuration( pipeline_config_identifier=pc_id, fallback_config_descriptor=self.config_1, sg_connection=self.mockgun, current_login="******" )
def setUp(self): super(TestTankFromPathDuplicatePcPaths, self).setUp() # define an additional pipeline config with overlapping paths self.overlapping_pc = { "type": "PipelineConfiguration", "code": "Primary", "id": 123456, "project": self.project, ShotgunPath.get_shotgun_storage_key(): self.project_root, } self.add_to_sg_mock_db(self.overlapping_pc)
def setUp(self): super(TestTankFromPathDuplicatePcPaths, self).setUp() # define an additional pipeline config with overlapping paths self.overlapping_pc = { "type": "PipelineConfiguration", "code": "Primary", "id": 123456, "project": self.project, ShotgunPath.get_shotgun_storage_key(): self.project_root, } self.add_to_sg_mock_db(self.overlapping_pc)
def validatePage(self): """The 'next' button was pushed. See if the mappings are valid.""" logger.debug("Validating the storage mappings page...") # the wizard instance and its UI wiz = self.wizard() ui = wiz.ui # clear any errors ui.storage_errors.setText("") # get the path key for the current os current_os_key = ShotgunPath.get_shotgun_storage_key() logger.debug("Current OS storage path key: %s" % (current_os_key, )) # temp lists of widgets that need attention invalid_widgets = [] not_on_disk_widgets = [] # keep track of the first invalid widget so we can ensure it is visible # to the user in the list. first_invalid_widget = None logger.debug("Checking all map widgets...") # see if each of the mappings is valid for map_widget in self._map_widgets: logger.debug("Checking mapping for root: %s" % (map_widget.root_name, )) if not map_widget.mapping_is_valid(): # something is wrong with this widget's mapping invalid_widgets.append(map_widget) if first_invalid_widget is None: first_invalid_widget = map_widget storage = map_widget.local_storage or {} current_os_path = storage.get(current_os_key) if current_os_path and not os.path.exists(current_os_path): # the current os path for this widget doesn't exist on disk not_on_disk_widgets.append(map_widget) if invalid_widgets: # tell the user which roots don't have valid mappings root_names = [w.root_name for w in invalid_widgets] logger.debug("Invalid mappings for roots: %s" % (root_names)) ui.storage_errors.setText( "The mappings for these roots are invalid: <b>%s</b>" % (", ".join(root_names), )) if first_invalid_widget: ui.storage_map_area.ensureWidgetVisible(first_invalid_widget) return False if not_on_disk_widgets: # try to create the folders for current OS if they don't exist failed_to_create = [] for widget in not_on_disk_widgets: storage = widget.local_storage folder = storage[current_os_key] logger.debug("Ensuring folder on disk for storage '%s': %s" % (storage["code"], folder)) # try to create the missing path for the current OS. this will # help ensure the storage specified in SG is valid and the # project data can be written to this root. try: ensure_folder_exists(folder) except Exception: logger.error("Failed to create folder: %s" % (folder, )) logger.error(traceback.format_exc()) failed_to_create.append(storage["code"]) if failed_to_create: # some folders weren't created. let the user know. ui.storage_errors.setText( "Unable to create folders on disk for these storages: %s." "Please check to make sure you have permission to create " "these folders. See the tk-desktop log for more info." % (", ".join(failed_to_create), )) # ---- now we've mapped the roots, and they're all valid, we need to # update the root information on the core wizard for map_widget in self._map_widgets: root_name = map_widget.root_name root_info = map_widget.root_info storage_data = map_widget.local_storage # populate the data defined prior to mapping updated_storage_data = root_info # update the mapped shotgun data updated_storage_data["shotgun_storage_id"] = storage_data["id"] updated_storage_data["linux_path"] = str( storage_data["linux_path"]) updated_storage_data["mac_path"] = str(storage_data["mac_path"]) updated_storage_data["windows_path"] = str( storage_data["windows_path"]) # now update the core wizard's root info wiz.core_wizard.update_storage_root(self._uri, root_name, updated_storage_data) # store the fact that we've mapped this root name with this # storage name. we can use this information to make better # guesses next time this user is mapping storages. self._historical_mappings[root_name] = storage_data["code"] self._settings.store(self.HISTORICAL_MAPPING_KEY, self._historical_mappings) logger.debug("Storage mappings are valid.") # if we made it here, then we should be valid. try: wiz.core_wizard.set_config_uri(self._uri) except Exception as e: error = ("Unknown error when setting the configuration uri:\n%s" % str(e)) logger.error(error) logger.error(traceback.print_exc()) ui.storage_errors.setText(error) return False return True
def validatePage(self): """The 'next' button was pushed. See if the mappings are valid.""" logger.debug("Validating the storage mappings page...") # the wizard instance and its UI wiz = self.wizard() ui = wiz.ui # clear any errors ui.storage_errors.setText("") # get the path key for the current os current_os_key = ShotgunPath.get_shotgun_storage_key() logger.debug("Current OS storage path key: %s" % (current_os_key,)) # temp lists of widgets that need attention invalid_widgets = [] not_on_disk_widgets = [] # keep track of the first invalid widget so we can ensure it is visible # to the user in the list. first_invalid_widget = None logger.debug("Checking all map widgets...") # see if each of the mappings is valid for map_widget in self._map_widgets: logger.debug( "Checking mapping for root: %s" % (map_widget.root_name,) ) if not map_widget.mapping_is_valid(): # something is wrong with this widget's mapping invalid_widgets.append(map_widget) if first_invalid_widget is None: first_invalid_widget = map_widget storage = map_widget.local_storage or {} current_os_path = storage.get(current_os_key) if current_os_path and not os.path.exists(current_os_path): # the current os path for this widget doesn't exist on disk not_on_disk_widgets.append(map_widget) if invalid_widgets: # tell the user which roots don't have valid mappings root_names = [w.root_name for w in invalid_widgets] logger.debug("Invalid mappings for roots: %s" % (root_names)) ui.storage_errors.setText( "The mappings for these roots are invalid: <b>%s</b>" % (", ".join(root_names),) ) if first_invalid_widget: ui.storage_map_area.ensureWidgetVisible(first_invalid_widget) return False if not_on_disk_widgets: # try to create the folders for current OS if they don't exist failed_to_create = [] for widget in not_on_disk_widgets: storage = widget.local_storage folder = storage[current_os_key] logger.debug( "Ensuring folder on disk for storage '%s': %s" % (storage["code"], folder) ) # try to create the missing path for the current OS. this will # help ensure the storage specified in SG is valid and the # project data can be written to this root. try: ensure_folder_exists(folder) except Exception: logger.error("Failed to create folder: %s" % (folder,)) logger.error(traceback.format_exc()) failed_to_create.append(storage["code"]) if failed_to_create: # some folders weren't created. let the user know. ui.storage_errors.setText( "Unable to create folders on disk for these storages: %s." "Please check to make sure you have permission to create " "these folders. See the tk-desktop log for more info." % (", ".join(failed_to_create),) ) # ---- now we've mapped the roots, and they're all valid, we need to # update the root information on the core wizard for map_widget in self._map_widgets: root_name = map_widget.root_name root_info = map_widget.root_info storage_data = map_widget.local_storage # populate the data defined prior to mapping updated_storage_data = root_info # update the mapped shotgun data updated_storage_data["shotgun_storage_id"] = storage_data["id"] updated_storage_data["linux_path"] = str(storage_data["linux_path"]) updated_storage_data["mac_path"] = str(storage_data["mac_path"]) updated_storage_data["windows_path"] = str( storage_data["windows_path"]) # now update the core wizard's root info wiz.core_wizard.update_storage_root( self._uri, root_name, updated_storage_data ) # store the fact that we've mapped this root name with this # storage name. we can use this information to make better # guesses next time this user is mapping storages. self._historical_mappings[root_name] = storage_data["code"] self._settings.store( self.HISTORICAL_MAPPING_KEY, self._historical_mappings ) logger.debug("Storage mappings are valid.") # if we made it here, then we should be valid. try: wiz.core_wizard.set_config_uri(self._uri) except Exception as e: error = ( "Unknown error when setting the configuration uri:\n%s" % str(e) ) logger.error(error) logger.error(traceback.print_exc()) ui.storage_errors.setText(error) return False return True